blob: ef3b97da8842af962b307da6f05a1c2aac857cab [file] [log] [blame]
Christian Heimese8954f82007-11-22 11:21:16 +00001Building Python using VC++ 9.0
2------------------------------
3This directory is used to build Python for Win32 platforms, e.g. Windows
42000, XP and Vista. It requires Microsoft Visual C++ 9.0
5(a.k.a. Visual Studio .NET 2008).
6(For other Windows platforms and compilers, see ../PC/readme.txt.)
7
Christian Heimes8b011402007-11-27 21:28:40 +00008All you need to do is open the workspace "pcbuild.sln" in Visual Studio,
9select the desired combination of configuration and platform and eventually
10build the solution. Unless you are going to debug a problem in the core or
11you are going to create an optimized build you want to select "Release" as
12configuration.
Christian Heimese8954f82007-11-22 11:21:16 +000013
Christian Heimes8b011402007-11-27 21:28:40 +000014The PCbuild9 directory is compatible with all versions of Visual Studio from
15VS C++ Express Edition over the standard edition up to the professional
16edition. However the express edition does support features like solution
17folders or profile guided optimization (PGO). The missing bits and pieces
18won't stop you from building Python.
Christian Heimese8954f82007-11-22 11:21:16 +000019
Christian Heimes8b011402007-11-27 21:28:40 +000020The solution is configured to build the projects in the correct order. "Build
21Solution" or F6 takes care of dependencies except for x64 builds. To make
22cross compiling x64 builds on a 32bit OS possible the x64 builds require a
2332bit version of Python.
Christian Heimese8954f82007-11-22 11:21:16 +000024
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 Heimes8b011402007-11-27 21:28:40 +000035The 32bit builds end up in the solution folder PCbuild9 while the x64 builds
36land in the amd64 subfolder. The PGI and PGO builds for profile guided
37optimization end up in their own folders, too.
38
Christian Heimese8954f82007-11-22 11:21:16 +000039SUBPROJECTS
40-----------
41These subprojects should build out of the box. Subprojects other than the
42main ones (pythoncore, python, pythonw) generally build a DLL (renamed to
43.pyd) from a specific module so that users don't have to load the code
44supporting that module unless they import the module.
45
46pythoncore
47 .dll and .lib
48python
49 .exe
50pythonw
51 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box
52_socket
53 socketmodule.c
54_testcapi
55 tests of the Python C API, run via Lib/test/test_capi.py, and
56 implemented by module Modules/_testcapimodule.c
57pyexpat
58 Python wrapper for accelerated XML parsing, which incorporates stable
59 code from the Expat project: http://sourceforge.net/projects/expat/
60select
61 selectmodule.c
62unicodedata
63 large tables of Unicode data
64winsound
65 play sounds (typically .wav files) under Windows
66
Christian Heimes8b011402007-11-27 21:28:40 +000067The following subprojects will generally NOT build out of the box. They
Christian Heimese8954f82007-11-22 11:21:16 +000068wrap code Python doesn't control, and you'll need to download the base
69packages first and unpack them into siblings of PCbuilds's parent
Christian Heimes8b011402007-11-27 21:28:40 +000070directory; for example, if your PCbuild9 is ..\dist\py3k\PCbuild9\,
71unpack into new subdirectories of ..\dist\.
Christian Heimese8954f82007-11-22 11:21:16 +000072
73_tkinter
74 Python wrapper for the Tk windowing system. Requires building
Christian Heimes4c07cd92007-12-05 19:57:54 +000075 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.16.
Christian Heimes8b011402007-11-27 21:28:40 +000076
77 NOTE: The 64 build builds must land in tcltk64 instead of tcltk.
Christian Heimese8954f82007-11-22 11:21:16 +000078
79 Get source
80 ----------
81 In the dist directory, run
Christian Heimes4c07cd92007-12-05 19:57:54 +000082 svn export http://svn.python.org/projects/external/tcl8.4.16
83 svn export http://svn.python.org/projects/external/tk8.4.16
Christian Heimese8954f82007-11-22 11:21:16 +000084 svn export http://svn.python.org/projects/external/tix-8.4.0
85
Christian Heimes4c07cd92007-12-05 19:57:54 +000086 Build with build_tkinter.py
87 ---------------------------
88 The PCbuild9 directory contains a Python script which automates all
89 steps. Run the script in a Visual Studio 2009 command prompt with
90
91 python build_tkinter.py Win32
92
93 Use x64 instead of Win32 for the x64 platform.
94
95 Build Tcl first
Christian Heimese8954f82007-11-22 11:21:16 +000096 ---------------
Christian Heimes4c07cd92007-12-05 19:57:54 +000097 Use "Start -> All Programs -> Microsoft Visual Studio 2008
98 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt"
Christian Heimese8954f82007-11-22 11:21:16 +000099 to get a shell window with the correct environment settings
Christian Heimes4c07cd92007-12-05 19:57:54 +0000100 cd dist\tcl8.4.16\win
Christian Heimese8954f82007-11-22 11:21:16 +0000101 nmake -f makefile.vc
102 nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
103
104 XXX Should we compile with OPTS=threads?
105
106 Optional: run tests, via
107 nmake -f makefile.vc test
108
109 On WinXP Pro, wholly up to date as of 30-Aug-2004:
110 all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0
111 Sourced 129 Test Files.
112
113 Build Tk
114 --------
Christian Heimes4c07cd92007-12-05 19:57:54 +0000115 cd dist\tk8.4.16\win
116 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16
117 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 INSTALLDIR=..\..\tcltk install
Christian Heimese8954f82007-11-22 11:21:16 +0000118
119 XXX Should we compile with OPTS=threads?
120
121 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
122 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
123
124 Optional: run tests, via
Christian Heimes4c07cd92007-12-05 19:57:54 +0000125 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 test
Christian Heimese8954f82007-11-22 11:21:16 +0000126
127 On WinXP Pro, wholly up to date as of 30-Aug-2004:
128 all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13
129 Sourced 91 Test Files.
130 Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test
131
132 Built Tix
133 ---------
134 cd dist\tix-8.4.0\win
Christian Heimes4c07cd92007-12-05 19:57:54 +0000135 nmake -f python9.mak
136 nmake -f python9.mak install
Christian Heimese8954f82007-11-22 11:21:16 +0000137
138bz2
139 Python wrapper for the libbz2 compression library. Homepage
140 http://sources.redhat.com/bzip2/
141 Download the source from the python.org copy into the dist
142 directory:
143
144 svn export http://svn.python.org/projects/external/bzip2-1.0.3
145
146 A custom pre-link step in the bz2 project settings should manage to
147 build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is
Christian Heimes8b011402007-11-27 21:28:40 +0000148 linked in PCbuild9\.
Christian Heimese8954f82007-11-22 11:21:16 +0000149 However, the bz2 project is not smart enough to remove anything under
150 bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib
151 you need to clean up bzip2-1.0.3\ by hand.
152
Christian Heimes8b011402007-11-27 21:28:40 +0000153 All of this managed to build libbz2.lib in
154 bzip2-1.0.3\$platform-$configuration\, which the Python project links in.
Christian Heimese8954f82007-11-22 11:21:16 +0000155
156
157_bsddb
158 To use the version of bsddb that Python is built with by default, invoke
159 (in the dist directory)
160
Christian Heimes8b011402007-11-27 21:28:40 +0000161 svn export http://svn.python.org/projects/external/db-4.4.20
Christian Heimese8954f82007-11-22 11:21:16 +0000162
Christian Heimes8b011402007-11-27 21:28:40 +0000163 Next open the solution file db-4.4.20\build_win32\Berkeley_DB.sln with
164 Visual Studio and convert the projects to the new format. The standard
165 and professional version of VS 2008 builds the necessary libraries
166 in a pre-link step of _bsddb. However the express edition is missing
167 some pieces and you have to build the libs yourself.
168
169 The _bsddb subprojects depends only on the db_static project of
170 Berkeley DB. You have to choose either "Release", "Release AMD64", "Debug"
171 or "Debug AMD64" as configuration.
Christian Heimese8954f82007-11-22 11:21:16 +0000172
173 Alternatively, if you want to start with the original sources,
174 go to Sleepycat's download page:
175 http://www.sleepycat.com/downloads/releasehistorybdb.html
176
177 and download version 4.4.20.
178
179 With or without strong cryptography? You can choose either with or
180 without strong cryptography, as per the instructions below. By
181 default, Python is built and distributed WITHOUT strong crypto.
182
183 Unpack the sources; if you downloaded the non-crypto version, rename
184 the directory from db-4.4.20.NC to db-4.4.20.
185
186 Now apply any patches that apply to your version.
187
188 Open
Christian Heimes8b011402007-11-27 21:28:40 +0000189 db-4.4.20\docs\ref\build_win\intro.html
Christian Heimese8954f82007-11-22 11:21:16 +0000190
191 and follow the "Windows->Building Berkeley DB with Visual C++ .NET"
192 instructions for building the Sleepycat
193 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
194 Build the "db_static" project, for "Release" mode.
195
196 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
197 is then enabled. Running in verbose mode may be helpful.
198
Christian Heimese8954f82007-11-22 11:21:16 +0000199_sqlite3
200 Python wrapper for SQLite library.
201
202 Get the source code through
203
204 svn export http://svn.python.org/projects/external/sqlite-source-3.3.4
205
206 To use the extension module in a Python build tree, copy sqlite3.dll into
Christian Heimes8b011402007-11-27 21:28:40 +0000207 the PCbuild folder. The source directory in svn also contains a .def file
208 from the binary release of sqlite3.
Christian Heimese8954f82007-11-22 11:21:16 +0000209
210_ssl
211 Python wrapper for the secure sockets library.
212
213 Get the source code through
214
215 svn export http://svn.python.org/projects/external/openssl-0.9.8g
216
217 Alternatively, get the latest version from http://www.openssl.org.
218 You can (theoretically) use any version of OpenSSL you like - the
219 build process will automatically select the latest version.
220
Christian Heimes3971f6b2007-11-30 19:18:08 +0000221 You must install the NASM assembler from
222 http://www.kernel.org/pub/software/devel/nasm/binaries/win32/
223 for x86 builds. Put nasmw.exe anywhere in your PATH.
224
225 You can also install ActivePerl from
Christian Heimese8954f82007-11-22 11:21:16 +0000226 http://www.activestate.com/Products/ActivePerl/
Christian Heimes8b011402007-11-27 21:28:40 +0000227 if you like to use the official sources instead of the files from
228 python's subversion repository. The svn version contains pre-build
229 makefiles and assembly files.
Christian Heimese8954f82007-11-22 11:21:16 +0000230
Christian Heimes8b011402007-11-27 21:28:40 +0000231 The build process makes sure that no patented algorithms are included.
232 For now RC5, MDC2 and IDEA are excluded from the build. You may have
233 to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process
234 complains about missing files or forbidden IDEA. Again the files provided
235 in the subversion repository are already fixed.
Christian Heimese8954f82007-11-22 11:21:16 +0000236
237 The MSVC project simply invokes PCBuild/build_ssl.py to perform
238 the build. This Python script locates and builds your OpenSSL
239 installation, then invokes a simple makefile to build the final .pyd.
240
241 build_ssl.py attempts to catch the most common errors (such as not
242 being able to find OpenSSL sources, or not being able to find a Perl
243 that works with OpenSSL) and give a reasonable error message.
244 If you have a problem that doesn't seem to be handled correctly
245 (eg, you know you have ActivePerl but we can't find it), please take
246 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
247 should be able to be run directly from the command-line.
248
249 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
250 this by hand.
251
252Building for Itanium
253--------------------
254
Christian Heimes8b011402007-11-27 21:28:40 +0000255NOTE:
256Official support for Itanium builds have been dropped from the build. Please
257contact as and provide patches if you are interested in Itanium builds.
258
Christian Heimese8954f82007-11-22 11:21:16 +0000259The project files support a ReleaseItanium configuration which creates
260Win64/Itanium binaries. For this to work, you need to install the Platform
261SDK, in particular the 64-bit support. This includes an Itanium compiler
262(future releases of the SDK likely include an AMD64 compiler as well).
263In addition, you need the Visual Studio plugin for external C compilers,
264from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to
265locate the proper target compiler, and convert compiler options
266accordingly. The project files require atleast version 0.9.
267
268Building for AMD64
269------------------
270
Christian Heimes8b011402007-11-27 21:28:40 +0000271The build process for AMD64 / x64 is very similar to standard builds. You just
272have to set x64 as platform.
Christian Heimese8954f82007-11-22 11:21:16 +0000273
274Building Python Using the free MS Toolkit Compiler
275--------------------------------------------------
276
Christian Heimes3971f6b2007-11-30 19:18:08 +0000277Microsoft has withdrawn the free MS Toolkit Compiler, so this can no longer
278be considered a supported option. Instead you can use the free VS C++ Express
279Edition.
Christian Heimese8954f82007-11-22 11:21:16 +0000280
Christian Heimes8b011402007-11-27 21:28:40 +0000281Profile Guided Optimization
282---------------------------
Christian Heimese8954f82007-11-22 11:21:16 +0000283
Christian Heimes3d2f5642007-12-06 21:13:06 +0000284The solution has two configurations for PGO. The PGInstrument configuration
285must be build first. The PGInstrument binaries are lniked against a profiling
286library and contain extra debug information. The PGUpdate configuration takes the profiling data and generates optimized binaries.
287
288The build_pgo.bat script automates the creation of optimized binaries. It
289creates the PGI files, runs the unit test suite or PyBench with the PGI
290python and finally creates the optimized files.
291
Christian Heimes8b011402007-11-27 21:28:40 +0000292http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx
Christian Heimese8954f82007-11-22 11:21:16 +0000293
Christian Heimes3971f6b2007-11-30 19:18:08 +0000294Static library
295--------------
296
297The solution has no configuration for static libraries. However it is easy
298it build a static library instead of a DLL. You simply have to set the
299"Configuration Type" to "Static Library (.lib)" and alter the preprocessor
300macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to
301change the "Runtime Library" from "Multi-threaded DLL (/MD)" to
302"Multi-threaded (/MT)".
303
Christian Heimes18679942007-12-05 21:57:25 +0000304Visual Studio properties
305------------------------
306
307The PCbuild9 solution makes heavy use of Visual Studio property files
308(*.vsprops). The properties can be viewed and altered in the Property
309Manager (View -> Other Windows -> Property Manager).
310
Christian Heimes3d2f5642007-12-06 21:13:06 +0000311 * debug (debug macro: _DEBUG)
Christian Heimes18679942007-12-05 21:57:25 +0000312 * pginstrument (PGO)
313 * pgupdate (PGO)
314 +-- pginstrument
315 * pyd (python extension, release build)
316 +-- release
317 +-- pyproject
318 * pyd_d (python extension, debug build)
319 +-- debug
320 +-- pyproject
Christian Heimes3d2f5642007-12-06 21:13:06 +0000321 * pyproject (base settings for all projects, user macros like PyDllName)
322 * release (release macro: NDEBUG)
Christian Heimes18679942007-12-05 21:57:25 +0000323 * x64 (AMD64 / x64 platform specific settings)
324
325The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64
326although the macros are set by the compiler, too. The GUI doesn't always know
327about the macros and confuse the user with false information.
328
Christian Heimese8954f82007-11-22 11:21:16 +0000329YOUR OWN EXTENSION DLLs
330-----------------------
Christian Heimes3d2f5642007-12-06 21:13:06 +0000331
Christian Heimese8954f82007-11-22 11:21:16 +0000332If you want to create your own extension module DLL, there's an example
333with easy-to-follow instructions in ../PC/example/; read the file
334readme.txt there first.