1 Building Python using VC++ 8.0
2 -------------------------------------
3 This directory is used to build Python for Win32 platforms, e.g. Windows
4 95, 98 and NT. It requires Microsoft Visual C++ 8.0
5 (a.k.a. Visual Studio 2005).
6 (For other Windows platforms and compilers, see ../PC/readme.txt.)
8 All you need to do is open the workspace "pcbuild.sln" in MSVC++, select
9 the Debug or Release setting (using "Solution Configuration" from
10 the "Standard" toolbar"), and build the projects.
12 The proper order to build subprojects:
14 1) pythoncore (this builds the main Python DLL and library files,
15 python26.{dll, lib} in Release mode)
16 NOTE: in previous releases, this subproject was
17 named after the release number, e.g. python20.
19 2) python (this builds the main Python executable,
20 python.exe in Release mode)
22 3) the other subprojects, as desired or needed (note: you probably don't
23 want to build most of the other subprojects, unless you're building an
24 entire Python distribution from scratch, or specifically making changes
25 to the subsystems they implement, or are running a Python core buildbot
26 test slave; see SUBPROJECTS below)
28 Binary files go into PCBuild8\Win32 or \x64 directories and don't
29 interfere with each other.
31 When using the Debug setting, the output files have a _d added to
32 their name: python26_d.dll, python_d.exe, parser_d.pyd, and so on.
34 There are two special configurations for the pythoncore project and
35 the solution. These are PGIRelease and PGORelease. They are for
36 createing profile-guided optimized versions of python.dll.
37 The former creates the instrumented binaries, and the latter
38 runs python.exe with the instrumented python.dll on the performance
39 testsuite, and creates a new, optimized, python.dll in
40 PCBuild8\Win32\PGORelease, or in the x64 folder. Note that although
41 we can cross-compile x64 binaries on a 32 bit machine, we cannot
42 create the PGO binaries, since they require actually running the code.
46 These subprojects should build out of the box. Subprojects other than the
47 main ones (pythoncore, python, pythonw) generally build a DLL (renamed to
48 .pyd) from a specific module so that users don't have to load the code
49 supporting that module unless they import the module.
56 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box
60 tests of the Python C API, run via Lib/test/test_capi.py, and
61 implemented by module Modules/_testcapimodule.c
63 Python wrapper for accelerated XML parsing, which incorporates stable
64 code from the Expat project: http://sourceforge.net/projects/expat/
68 large tables of Unicode data
70 play sounds (typically .wav files) under Windows
72 The following subprojects will generally NOT build out of the box. They
73 wrap code Python doesn't control, and you'll need to download the base
74 packages first and unpack them into siblings of PCbuilds's parent
75 directory; for example, if your PCbuild is .......\dist\src\PCbuild\,
76 unpack into new subdirectories of dist\.
79 Python wrapper for the Tk windowing system. Requires building
80 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12.
84 In the dist directory, run
85 svn export http://svn.python.org/projects/external/tcl8.4.12
86 svn export http://svn.python.org/projects/external/tk8.4.12
87 svn export http://svn.python.org/projects/external/tix-8.4.0
89 Build Tcl first (done here w/ MSVC 7.1 on Windows XP)
91 Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003
92 -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt"
93 to get a shell window with the correct environment settings
96 nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
98 XXX Should we compile with OPTS=threads?
100 Optional: run tests, via
101 nmake -f makefile.vc test
103 On WinXP Pro, wholly up to date as of 30-Aug-2004:
104 all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0
105 Sourced 129 Test Files.
110 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12
111 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install
113 XXX Should we compile with OPTS=threads?
115 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
116 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
118 Optional: run tests, via
119 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test
121 On WinXP Pro, wholly up to date as of 30-Aug-2004:
122 all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13
123 Sourced 91 Test Files.
124 Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test
128 cd dist\tix-8.4.0\win
130 nmake -f python.mak install
133 Python wrapper for the libbz2 compression library. Homepage
134 http://sources.redhat.com/bzip2/
135 Download the source from the python.org copy into the dist
138 svn export http://svn.python.org/projects/external/bzip2-1.0.3
140 A custom pre-link step in the bz2 project settings should manage to
141 build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is
143 However, the bz2 project is not smart enough to remove anything under
144 bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib
145 you need to clean up bzip2-1.0.3\ by hand.
147 The build step shouldn't yield any warnings or errors, and should end
148 by displaying 6 blocks each terminated with
149 FC: no differences encountered
151 All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python
156 To use the version of bsddb that Python is built with by default, invoke
157 (in the dist directory)
159 svn export http://svn.python.org/projects/external/db-4.4.20
162 Then open a VS.NET 2003 shell, and invoke:
164 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Release /project db_static
166 and do that a second time for a Debug build too:
168 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static
170 Alternatively, if you want to start with the original sources,
171 go to Sleepycat's download page:
172 http://www.sleepycat.com/downloads/releasehistorybdb.html
174 and download version 4.4.20.
176 With or without strong cryptography? You can choose either with or
177 without strong cryptography, as per the instructions below. By
178 default, Python is built and distributed WITHOUT strong crypto.
180 Unpack the sources; if you downloaded the non-crypto version, rename
181 the directory from db-4.4.20.NC to db-4.4.20.
183 Now apply any patches that apply to your version.
186 dist\db-4.4.20\docs\index.html
188 and follow the "Windows->Building Berkeley DB with Visual C++ .NET"
189 instructions for building the Sleepycat
190 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
191 Build the "db_static" project, for "Release" mode.
193 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
194 is then enabled. Running in verbose mode may be helpful.
196 XXX The test_bsddb3 tests don't always pass, on Windows (according to
197 XXX me) or on Linux (according to Barry). (I had much better luck
198 XXX on Win2K than on Win98SE.) The common failure mode across platforms
200 XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable
201 XXX to join the environment')
203 XXX and it appears timing-dependent. On Win2K I also saw this once:
205 XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ...
206 XXX Exception in thread reader 1:
207 XXX Traceback (most recent call last):
208 XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap
210 XXX File "C:\Code\python\lib\threading.py", line 399, in run
211 XXX apply(self.__target, self.__args, self.__kwargs)
212 XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in
215 XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed
216 XXX to resolve a deadlock')
218 XXX I'm told that DBLockDeadlockError is expected at times. It
219 XXX doesn't cause a test to fail when it happens (exceptions in
220 XXX threads are invisible to unittest).
223 - open a VS.NET 2003 command prompt
224 - run the SDK setenv.cmd script, passing /RETAIL and the target
225 architecture (/SRV64 for Itanium, /X64 for AMD64)
226 - build BerkeleyDB with the solution configuration matching the
227 target ("Release IA64" for Itanium, "Release AMD64" for AMD64), e.g.
228 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build "Release AMD64" /project db_static /useenv
231 Python wrapper for SQLite library.
233 Get the source code through
235 svn export http://svn.python.org/projects/external/sqlite-source-3.3.4
237 To use the extension module in a Python build tree, copy sqlite3.dll into
241 Python wrapper for the secure sockets library.
243 Get the source code through
245 svn export http://svn.python.org/projects/external/openssl-0.9.8a
247 Alternatively, get the latest version from http://www.openssl.org.
248 You can (theoretically) use any version of OpenSSL you like - the
249 build process will automatically select the latest version.
251 You must also install ActivePerl from
252 http://www.activestate.com/Products/ActivePerl/
253 as this is used by the OpenSSL build process. Complain to them <wink>.
255 The MSVC project simply invokes PCBuild/build_ssl.py to perform
256 the build. This Python script locates and builds your OpenSSL
257 installation, then invokes a simple makefile to build the final .pyd.
259 build_ssl.py attempts to catch the most common errors (such as not
260 being able to find OpenSSL sources, or not being able to find a Perl
261 that works with OpenSSL) and give a reasonable error message.
262 If you have a problem that doesn't seem to be handled correctly
263 (eg, you know you have ActivePerl but we can't find it), please take
264 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
265 should be able to be run directly from the command-line.
267 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
273 The project files support a ReleaseItanium configuration which creates
274 Win64/Itanium binaries. For this to work, you need to install the Platform
275 SDK, in particular the 64-bit support. This includes an Itanium compiler
276 (future releases of the SDK likely include an AMD64 compiler as well).
277 In addition, you need the Visual Studio plugin for external C compilers,
278 from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to
279 locate the proper target compiler, and convert compiler options
280 accordingly. The project files require atleast version 0.8.
285 The build process for the ReleaseAMD64 configuration is very similar
286 to the Itanium configuration; make sure you use the latest version of
289 Building Python Using the free MS Toolkit Compiler
290 --------------------------------------------------
292 The build process for Visual C++ can be used almost unchanged with the free MS
293 Toolkit Compiler. This provides a way of building Python using freely
298 To build Python, the following tools are required:
300 * The Visual C++ Toolkit Compiler
301 from http://msdn.microsoft.com/visualc/vctoolkit2003/
302 * A recent Platform SDK
303 from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a
305 from http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d
307 [Does anyone have better URLs for the last 2 of these?]
309 The toolkit compiler is needed as it is an optimising compiler (the
310 compiler supplied with the .NET SDK is a non-optimising version). The
311 platform SDK is needed to provide the Windows header files and libraries
312 (the Windows 2003 Server SP1 edition, typical install, is known to work -
313 other configurations or versions are probably fine as well). The .NET 1.1
314 SDK is needed because it contains a version of msvcrt.dll which links to
315 the msvcr71.dll CRT. Note that the .NET 2.0 SDK is NOT acceptable, as it
316 references msvcr80.dll.
318 All of the above items should be installed as normal.
320 If you intend to build the openssl (needed for the _ssl extension) you
321 will need the C runtime sources installed as part of the platform SDK.
323 In addition, you will need Nant, available from
324 http://nant.sourceforge.net. The 0.85 release candidate 3 version is known
325 to work. This is the latest released version at the time of writing. Later
326 "nightly build" versions are known NOT to work - it is not clear at
327 present whether future released versions will work.
329 Setting up the environment
331 Start a platform SDK "build environment window" from the start menu. The
332 "Windows XP 32-bit retail" version is known to work.
334 Add the following directories to your PATH:
335 * The toolkit compiler directory
336 * The SDK "Win64" binaries directory
338 Add to your INCLUDE environment variable:
339 * The toolkit compiler INCLUDE directory
340 Add to your LIB environment variable:
341 * The toolkit compiler LIB directory
342 * The .NET SDK Visual Studio 2003 VC7\lib directory
344 The following commands should set things up as you need them:
346 rem Set these values according to where you installed the software
347 set TOOLKIT=C:\Program Files\Microsoft Visual C++ Toolkit 2003
348 set SDK=C:\Program Files\Microsoft Platform SDK
349 set NET=C:\Program Files\Microsoft Visual Studio .NET 2003
350 set NANT=C:\Utils\Nant
352 set PATH=%TOOLKIT%\bin;%PATH%;%SDK%\Bin\win64;%NANT%\bin
353 set INCLUDE=%TOOLKIT%\include;%INCLUDE%
354 set LIB=%TOOLKIT%\lib;%NET%\VC7\lib;%LIB%
356 The "win64" directory from the SDK is added to supply executables such as
357 "cvtres" and "lib", which are not available elsewhere. The versions in the
358 "win64" directory are 32-bit programs, so they are fine to use here.
360 That's it. To build Python (the core only, no binary extensions which
361 depend on external libraries) you just need to issue the command
363 nant -buildfile:python.build all
365 from within the PCBuild directory.
369 To build those extension modules which require external libraries
370 (_tkinter, bz2, _bsddb, _sqlite3, _ssl) you can follow the instructions
371 for the Visual Studio build above, with a few minor modifications. These
372 instructions have only been tested using the sources in the Python
373 subversion repository - building from original sources should work, but
376 For each extension module you wish to build, you should remove the
377 associated include line from the excludeprojects section of pc.build.
379 The changes required are:
382 The tix makefile (tix-8.4.0\win\makefile.vc) must be modified to
383 remove references to TOOLS32. The relevant lines should be changed to
388 The remainder of the build instructions will work as given.
391 No changes are needed
394 The file db.build should be copied from the Python PCBuild directory
395 to the directory db-4.4.20\build_win32.
397 The file db_static.vcproj in db-4.4.20\build_win32 should be edited to
398 remove the string "$(SolutionDir)" - this occurs in 2 places, only
399 relevant for 64-bit builds. (The edit is required as otherwise, nant
400 wants to read the solution file, which is not in a suitable form).
402 The bsddb library can then be build with the command
403 nant -buildfile:db.build all
404 run from the db-4.4.20\build_win32 directory.
407 No changes are needed. However, in order for the tests to succeed, a
408 copy of sqlite3.dll must be downloaded, and placed alongside
412 The documented build process works as written. However, it needs a
413 copy of the file setargv.obj, which is not supplied in the platform
414 SDK. However, the sources are available (in the crt source code). To
415 build setargv.obj, proceed as follows:
417 Copy setargv.c, cruntime.h and internal.h from %SDK%\src\crt to a
419 Compile using "cl /c /I. /MD /D_CRTBLD setargv.c"
420 Copy the resulting setargv.obj to somewhere on your LIB environment
421 (%SDK%\lib is a reasonable place).
423 With setargv.obj in place, the standard build process should work
426 YOUR OWN EXTENSION DLLs
427 -----------------------
428 If you want to create your own extension module DLL, there's an example
429 with easy-to-follow instructions in ../PC/example/; read the file
430 readme.txt there first.