blob: 2b2d1f861c289c767afbbdbd416bdf7611a2ae99 [file] [log] [blame]
Christian Heimese8954f82007-11-22 11:21:16 +00001Building Python using VC++ 9.0
2------------------------------
Christian Heimesd9fbab22008-01-02 17:43:40 +00003
Christian Heimese8954f82007-11-22 11:21:16 +00004This directory is used to build Python for Win32 platforms, e.g. Windows
52000, XP and Vista. It requires Microsoft Visual C++ 9.0
6(a.k.a. Visual Studio .NET 2008).
7(For other Windows platforms and compilers, see ../PC/readme.txt.)
8
Christian Heimes8b011402007-11-27 21:28:40 +00009All you need to do is open the workspace "pcbuild.sln" in Visual Studio,
10select the desired combination of configuration and platform and eventually
11build the solution. Unless you are going to debug a problem in the core or
12you are going to create an optimized build you want to select "Release" as
13configuration.
Christian Heimese8954f82007-11-22 11:21:16 +000014
Christian Heimes3adfe9a2007-12-31 15:18:55 +000015The PCbuild directory is compatible with all versions of Visual Studio from
Christian Heimes8b011402007-11-27 21:28:40 +000016VS C++ Express Edition over the standard edition up to the professional
17edition. However the express edition does support features like solution
18folders or profile guided optimization (PGO). The missing bits and pieces
19won't stop you from building Python.
Christian Heimese8954f82007-11-22 11:21:16 +000020
Christian Heimes8b011402007-11-27 21:28:40 +000021The solution is configured to build the projects in the correct order. "Build
22Solution" or F6 takes care of dependencies except for x64 builds. To make
23cross compiling x64 builds on a 32bit OS possible the x64 builds require a
2432bit version of Python.
Christian Heimese8954f82007-11-22 11:21:16 +000025
Christian Heimes3971f6b2007-11-30 19:18:08 +000026NOTE:
27 You probably don't want to build most of the other subprojects, unless
Christian Heimes8b011402007-11-27 21:28:40 +000028 you're building an entire Python distribution from scratch, or
29 specifically making changes to the subsystems they implement, or are
30 running a Python core buildbot test slave; see SUBPROJECTS below)
Christian Heimese8954f82007-11-22 11:21:16 +000031
32When using the Debug setting, the output files have a _d added to
33their name: python30_d.dll, python_d.exe, parser_d.pyd, and so on.
34
Christian Heimes3adfe9a2007-12-31 15:18:55 +000035The 32bit builds end up in the solution folder PCbuild while the x64 builds
Christian Heimes8b011402007-11-27 21:28:40 +000036land in the amd64 subfolder. The PGI and PGO builds for profile guided
37optimization end up in their own folders, too.
38
Christian Heimesd9fbab22008-01-02 17:43:40 +000039Legacy support
40--------------
41
42You can find build directories for older versions of Visual Studio and
43Visual C++ in the PC directory. The legacy build directories are no longer
44actively maintained and may not work out of the box.
45
46PC/VC6/
47 Visual C++ 6.0
48PC/VS7.1/
49 Visual Studio 2003 (7.1)
50PCbuild8/
51 Visual Studio 2005 (8.0)
52
53
54C RUNTIME
55---------
56
57Visual Studio 2008 uses version 9 of the C runtime (MSVCRT9). The executables
58are linked to a CRT "side by side" assembly which must be present on the target
59machine. This is avalible under the VC/Redist folder of your visual studio
60distribution. On XP and later operating systems that support
61side-by-side assemblies it is not enough to have the msvcrt80.dll present,
62it has to be there as a whole assembly, that is, a folder with the .dll
63and a .manifest. Also, a check is made for the correct version.
64Therefore, one should distribute this assembly with the dlls, and keep
65it in the same directory. For compatibility with older systems, one should
66also set the PATH to this directory so that the dll can be found.
67For more info, see the Readme in the VC/Redist folder.
68
Christian Heimese8954f82007-11-22 11:21:16 +000069SUBPROJECTS
70-----------
71These subprojects should build out of the box. Subprojects other than the
72main ones (pythoncore, python, pythonw) generally build a DLL (renamed to
73.pyd) from a specific module so that users don't have to load the code
74supporting that module unless they import the module.
75
76pythoncore
77 .dll and .lib
78python
79 .exe
80pythonw
81 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box
82_socket
83 socketmodule.c
84_testcapi
85 tests of the Python C API, run via Lib/test/test_capi.py, and
86 implemented by module Modules/_testcapimodule.c
87pyexpat
88 Python wrapper for accelerated XML parsing, which incorporates stable
89 code from the Expat project: http://sourceforge.net/projects/expat/
90select
91 selectmodule.c
92unicodedata
93 large tables of Unicode data
94winsound
95 play sounds (typically .wav files) under Windows
96
Christian Heimes8b011402007-11-27 21:28:40 +000097The following subprojects will generally NOT build out of the box. They
Christian Heimese8954f82007-11-22 11:21:16 +000098wrap code Python doesn't control, and you'll need to download the base
99packages first and unpack them into siblings of PCbuilds's parent
Christian Heimes3adfe9a2007-12-31 15:18:55 +0000100directory; for example, if your PCbuild is ..\dist\py3k\PCbuild\,
Christian Heimes8b011402007-11-27 21:28:40 +0000101unpack into new subdirectories of ..\dist\.
Christian Heimese8954f82007-11-22 11:21:16 +0000102
103_tkinter
104 Python wrapper for the Tk windowing system. Requires building
Christian Heimes4c07cd92007-12-05 19:57:54 +0000105 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.16.
Christian Heimes8b011402007-11-27 21:28:40 +0000106
107 NOTE: The 64 build builds must land in tcltk64 instead of tcltk.
Christian Heimese8954f82007-11-22 11:21:16 +0000108
109 Get source
110 ----------
111 In the dist directory, run
Christian Heimes4c07cd92007-12-05 19:57:54 +0000112 svn export http://svn.python.org/projects/external/tcl8.4.16
113 svn export http://svn.python.org/projects/external/tk8.4.16
Christian Heimese8954f82007-11-22 11:21:16 +0000114 svn export http://svn.python.org/projects/external/tix-8.4.0
115
Christian Heimes4c07cd92007-12-05 19:57:54 +0000116 Build with build_tkinter.py
117 ---------------------------
Christian Heimes3adfe9a2007-12-31 15:18:55 +0000118 The PCbuild directory contains a Python script which automates all
Thomas Heller44c38c12008-01-10 18:45:40 +0000119 steps. Run the script in a Visual Studio 2008 command prompt with
Christian Heimes4c07cd92007-12-05 19:57:54 +0000120
121 python build_tkinter.py Win32
122
123 Use x64 instead of Win32 for the x64 platform.
124
125 Build Tcl first
Christian Heimese8954f82007-11-22 11:21:16 +0000126 ---------------
Christian Heimes4c07cd92007-12-05 19:57:54 +0000127 Use "Start -> All Programs -> Microsoft Visual Studio 2008
128 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt"
Christian Heimese8954f82007-11-22 11:21:16 +0000129 to get a shell window with the correct environment settings
Christian Heimes4c07cd92007-12-05 19:57:54 +0000130 cd dist\tcl8.4.16\win
Christian Heimese8954f82007-11-22 11:21:16 +0000131 nmake -f makefile.vc
132 nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
133
134 XXX Should we compile with OPTS=threads?
135
136 Optional: run tests, via
137 nmake -f makefile.vc test
138
139 On WinXP Pro, wholly up to date as of 30-Aug-2004:
140 all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0
141 Sourced 129 Test Files.
142
143 Build Tk
144 --------
Christian Heimes4c07cd92007-12-05 19:57:54 +0000145 cd dist\tk8.4.16\win
146 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16
147 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 INSTALLDIR=..\..\tcltk install
Christian Heimese8954f82007-11-22 11:21:16 +0000148
149 XXX Should we compile with OPTS=threads?
150
151 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
152 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
153
154 Optional: run tests, via
Christian Heimes4c07cd92007-12-05 19:57:54 +0000155 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 test
Christian Heimese8954f82007-11-22 11:21:16 +0000156
157 On WinXP Pro, wholly up to date as of 30-Aug-2004:
158 all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13
159 Sourced 91 Test Files.
160 Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test
161
162 Built Tix
163 ---------
164 cd dist\tix-8.4.0\win
Christian Heimes4c07cd92007-12-05 19:57:54 +0000165 nmake -f python9.mak
166 nmake -f python9.mak install
Christian Heimese8954f82007-11-22 11:21:16 +0000167
168bz2
169 Python wrapper for the libbz2 compression library. Homepage
170 http://sources.redhat.com/bzip2/
171 Download the source from the python.org copy into the dist
172 directory:
173
174 svn export http://svn.python.org/projects/external/bzip2-1.0.3
175
176 A custom pre-link step in the bz2 project settings should manage to
177 build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is
Christian Heimes3adfe9a2007-12-31 15:18:55 +0000178 linked in PCbuild\.
Christian Heimese8954f82007-11-22 11:21:16 +0000179 However, the bz2 project is not smart enough to remove anything under
180 bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib
181 you need to clean up bzip2-1.0.3\ by hand.
182
Christian Heimes8b011402007-11-27 21:28:40 +0000183 All of this managed to build libbz2.lib in
184 bzip2-1.0.3\$platform-$configuration\, which the Python project links in.
Christian Heimese8954f82007-11-22 11:21:16 +0000185
186
187_bsddb
188 To use the version of bsddb that Python is built with by default, invoke
189 (in the dist directory)
190
Christian Heimes8b011402007-11-27 21:28:40 +0000191 svn export http://svn.python.org/projects/external/db-4.4.20
Christian Heimese8954f82007-11-22 11:21:16 +0000192
Christian Heimes8b011402007-11-27 21:28:40 +0000193 Next open the solution file db-4.4.20\build_win32\Berkeley_DB.sln with
Christian Heimes3af3ecc2008-02-03 14:34:18 +0000194 Visual Studio and convert the projects to the new format. VS 2008
195 builds the necessary libraries in a pre-link step of _bsddb. You
196 have to add "$(VCInstallDir)vcpackages" to the search path first
197 (Tools -> Options -> Projects and Solutions -> VC++ Directories,
198 Platform: Win32, Show directories for: Executable files).
Christian Heimes8b011402007-11-27 21:28:40 +0000199
200 The _bsddb subprojects depends only on the db_static project of
201 Berkeley DB. You have to choose either "Release", "Release AMD64", "Debug"
202 or "Debug AMD64" as configuration.
Christian Heimese8954f82007-11-22 11:21:16 +0000203
204 Alternatively, if you want to start with the original sources,
205 go to Sleepycat's download page:
206 http://www.sleepycat.com/downloads/releasehistorybdb.html
207
208 and download version 4.4.20.
209
210 With or without strong cryptography? You can choose either with or
211 without strong cryptography, as per the instructions below. By
212 default, Python is built and distributed WITHOUT strong crypto.
213
214 Unpack the sources; if you downloaded the non-crypto version, rename
215 the directory from db-4.4.20.NC to db-4.4.20.
216
217 Now apply any patches that apply to your version.
218
219 Open
Christian Heimes8b011402007-11-27 21:28:40 +0000220 db-4.4.20\docs\ref\build_win\intro.html
Christian Heimese8954f82007-11-22 11:21:16 +0000221
222 and follow the "Windows->Building Berkeley DB with Visual C++ .NET"
223 instructions for building the Sleepycat
224 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
225 Build the "db_static" project, for "Release" mode.
226
227 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
228 is then enabled. Running in verbose mode may be helpful.
229
Christian Heimese8954f82007-11-22 11:21:16 +0000230_sqlite3
231 Python wrapper for SQLite library.
232
233 Get the source code through
234
235 svn export http://svn.python.org/projects/external/sqlite-source-3.3.4
236
237 To use the extension module in a Python build tree, copy sqlite3.dll into
Christian Heimes8b011402007-11-27 21:28:40 +0000238 the PCbuild folder. The source directory in svn also contains a .def file
239 from the binary release of sqlite3.
Christian Heimese8954f82007-11-22 11:21:16 +0000240
241_ssl
242 Python wrapper for the secure sockets library.
243
244 Get the source code through
245
246 svn export http://svn.python.org/projects/external/openssl-0.9.8g
247
248 Alternatively, get the latest version from http://www.openssl.org.
249 You can (theoretically) use any version of OpenSSL you like - the
250 build process will automatically select the latest version.
251
Christian Heimes3971f6b2007-11-30 19:18:08 +0000252 You must install the NASM assembler from
253 http://www.kernel.org/pub/software/devel/nasm/binaries/win32/
254 for x86 builds. Put nasmw.exe anywhere in your PATH.
255
256 You can also install ActivePerl from
Christian Heimese8954f82007-11-22 11:21:16 +0000257 http://www.activestate.com/Products/ActivePerl/
Christian Heimes8b011402007-11-27 21:28:40 +0000258 if you like to use the official sources instead of the files from
259 python's subversion repository. The svn version contains pre-build
260 makefiles and assembly files.
Christian Heimese8954f82007-11-22 11:21:16 +0000261
Christian Heimes8b011402007-11-27 21:28:40 +0000262 The build process makes sure that no patented algorithms are included.
263 For now RC5, MDC2 and IDEA are excluded from the build. You may have
264 to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process
265 complains about missing files or forbidden IDEA. Again the files provided
266 in the subversion repository are already fixed.
Christian Heimese8954f82007-11-22 11:21:16 +0000267
268 The MSVC project simply invokes PCBuild/build_ssl.py to perform
269 the build. This Python script locates and builds your OpenSSL
270 installation, then invokes a simple makefile to build the final .pyd.
271
272 build_ssl.py attempts to catch the most common errors (such as not
273 being able to find OpenSSL sources, or not being able to find a Perl
274 that works with OpenSSL) and give a reasonable error message.
275 If you have a problem that doesn't seem to be handled correctly
276 (eg, you know you have ActivePerl but we can't find it), please take
277 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
278 should be able to be run directly from the command-line.
279
280 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
281 this by hand.
282
283Building for Itanium
284--------------------
285
Christian Heimes8b011402007-11-27 21:28:40 +0000286NOTE:
287Official support for Itanium builds have been dropped from the build. Please
288contact as and provide patches if you are interested in Itanium builds.
289
Christian Heimese8954f82007-11-22 11:21:16 +0000290The project files support a ReleaseItanium configuration which creates
291Win64/Itanium binaries. For this to work, you need to install the Platform
292SDK, in particular the 64-bit support. This includes an Itanium compiler
293(future releases of the SDK likely include an AMD64 compiler as well).
294In addition, you need the Visual Studio plugin for external C compilers,
295from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to
296locate the proper target compiler, and convert compiler options
297accordingly. The project files require atleast version 0.9.
298
299Building for AMD64
300------------------
301
Christian Heimes8b011402007-11-27 21:28:40 +0000302The build process for AMD64 / x64 is very similar to standard builds. You just
303have to set x64 as platform.
Christian Heimese8954f82007-11-22 11:21:16 +0000304
305Building Python Using the free MS Toolkit Compiler
306--------------------------------------------------
307
Christian Heimes3971f6b2007-11-30 19:18:08 +0000308Microsoft has withdrawn the free MS Toolkit Compiler, so this can no longer
309be considered a supported option. Instead you can use the free VS C++ Express
310Edition.
Christian Heimese8954f82007-11-22 11:21:16 +0000311
Christian Heimes8b011402007-11-27 21:28:40 +0000312Profile Guided Optimization
313---------------------------
Christian Heimese8954f82007-11-22 11:21:16 +0000314
Thomas Heller44c38c12008-01-10 18:45:40 +0000315The solution has two configurations for PGO. The PGInstrument
316configuration must be build first. The PGInstrument binaries are
317lniked against a profiling library and contain extra debug
318information. The PGUpdate configuration takes the profiling data and
319generates optimized binaries.
Christian Heimes3d2f5642007-12-06 21:13:06 +0000320
321The build_pgo.bat script automates the creation of optimized binaries. It
322creates the PGI files, runs the unit test suite or PyBench with the PGI
323python and finally creates the optimized files.
324
Christian Heimes8b011402007-11-27 21:28:40 +0000325http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx
Christian Heimese8954f82007-11-22 11:21:16 +0000326
Christian Heimes3971f6b2007-11-30 19:18:08 +0000327Static library
328--------------
329
330The solution has no configuration for static libraries. However it is easy
331it build a static library instead of a DLL. You simply have to set the
332"Configuration Type" to "Static Library (.lib)" and alter the preprocessor
333macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to
334change the "Runtime Library" from "Multi-threaded DLL (/MD)" to
335"Multi-threaded (/MT)".
336
Christian Heimes18679942007-12-05 21:57:25 +0000337Visual Studio properties
338------------------------
339
Christian Heimes3adfe9a2007-12-31 15:18:55 +0000340The PCbuild solution makes heavy use of Visual Studio property files
Christian Heimes18679942007-12-05 21:57:25 +0000341(*.vsprops). The properties can be viewed and altered in the Property
342Manager (View -> Other Windows -> Property Manager).
343
Christian Heimes3d2f5642007-12-06 21:13:06 +0000344 * debug (debug macro: _DEBUG)
Christian Heimes18679942007-12-05 21:57:25 +0000345 * pginstrument (PGO)
346 * pgupdate (PGO)
347 +-- pginstrument
348 * pyd (python extension, release build)
349 +-- release
350 +-- pyproject
351 * pyd_d (python extension, debug build)
352 +-- debug
353 +-- pyproject
Christian Heimes3d2f5642007-12-06 21:13:06 +0000354 * pyproject (base settings for all projects, user macros like PyDllName)
355 * release (release macro: NDEBUG)
Christian Heimes18679942007-12-05 21:57:25 +0000356 * x64 (AMD64 / x64 platform specific settings)
357
358The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64
359although the macros are set by the compiler, too. The GUI doesn't always know
360about the macros and confuse the user with false information.
361
Christian Heimese8954f82007-11-22 11:21:16 +0000362YOUR OWN EXTENSION DLLs
363-----------------------
Christian Heimes3d2f5642007-12-06 21:13:06 +0000364
Christian Heimese8954f82007-11-22 11:21:16 +0000365If you want to create your own extension module DLL, there's an example
366with easy-to-follow instructions in ../PC/example/; read the file
367readme.txt there first.