blob: eb8cd311b15a5414de63e6945da9c1bb170c2129 [file] [log] [blame]
Thomas Wouters4d70c3d2006-06-08 14:42:34 +00001Building Python using VC++ 8.0
2-------------------------------------
3This directory is used to build Python for Win32 platforms, e.g. Windows
495, 98 and NT. It requires Microsoft Visual C++ 8.0
Guido van Rossum360e4b82007-05-14 22:51:27 +00005(a.k.a. Visual Studio 2005). There are two Platforms defined, Win32
6and x64.
Thomas Wouters4d70c3d2006-06-08 14:42:34 +00007(For other Windows platforms and compilers, see ../PC/readme.txt.)
8
9All you need to do is open the workspace "pcbuild.sln" in MSVC++, select
10the Debug or Release setting (using "Solution Configuration" from
Guido van Rossum360e4b82007-05-14 22:51:27 +000011the "Standard" toolbar"), and build the solution.
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000012
Guido van Rossum360e4b82007-05-14 22:51:27 +000013A .bat file, build.bat, is provided to simplify command line builds.
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000014
Guido van Rossum360e4b82007-05-14 22:51:27 +000015Some of the subprojects rely on external libraries and won't build
16unless you have them installed.
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000017
Guido van Rossum360e4b82007-05-14 22:51:27 +000018Binary files go into PCBuild8\$(PlatformName)($ConfigurationName),
19which will be something like Win32Debug, Win32Release, x64Release, etc.
Thomas Wouters89f507f2006-12-13 04:49:30 +000020
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000021When using the Debug setting, the output files have a _d added to
Thomas Wouters89f507f2006-12-13 04:49:30 +000022their name: python26_d.dll, python_d.exe, parser_d.pyd, and so on.
23
Guido van Rossum360e4b82007-05-14 22:51:27 +000024PROFILER GUIDED OPTIMIZATION
25----------------------------
26There are two special solution configurations for Profiler Guided
27Optimization. Careful use of this has been shown to yield more than
2810% extra speed.
291) Build the PGInstrument solution configuration. This will yield
30binaries in the win32PGO or x64PGO folders. (You may want do start
31by erasing any .pgc files there, present from earlier runs.)
322) Instrument the binaries. Do this by for example running the test
33suite: win32PGO\python.exe ..\lib\test\regrtest.py. This will excercise
34python thoroughly.
353) Build the PGUpdate solution configuration (You may need to ask it
36to rebuild.) This will incorporate the information gathered in step 2
37and produce new binaries in the same win32PGO or x64pPGO folders.
384) (optional) You can continue to build the PGUpdate configuration as
39you work on python. It will continue to use the data from step 2, even
40if you add or modify files as part of your work. Thus, it makes sense to
41run steps 1 and 2 maybe once a week, and then use step 3) for all regular
42work.
43
44A .bat file, build_pgo.bat is included to automate this process
45
46You can convince yourself of the benefits of the PGO by comparing the
47results of the python testsuite with the regular Release build.
48
49
50C RUNTIME
51---------
52Visual Studio 2005 uses version 8 of the C runtime. The executables are
53linked to a CRT "side by side" assembly which must be present on the target
54machine. This is avalible under the VC/Redist folder of your visual studio
55distribution. Note that ServicePack1 of Visual Studio 2005 has a different
56version than the original. On XP and later operating systems that support
57side-by-side assemblies it is not enough to have the msvcrt80.dll present,
58it has to be there as a whole assembly, that is, a folder with the .dll
59and a .manifest. Also, a check is made for the correct version.
60Therefore, one should distribute this assembly with the dlls, and keep
61it in the same directory. For compatibility with older systems, one should
62also set the PATH to this directory so that the dll can be found.
63For more info, see the Readme in the VC/Redist folder.
64
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000065
66SUBPROJECTS
67-----------
68These subprojects should build out of the box. Subprojects other than the
69main ones (pythoncore, python, pythonw) generally build a DLL (renamed to
70.pyd) from a specific module so that users don't have to load the code
71supporting that module unless they import the module.
72
73pythoncore
74 .dll and .lib
Thomas Wouters4d70c3d2006-06-08 14:42:34 +000075python
76 .exe
77pythonw
78 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box
79_socket
80 socketmodule.c
81_testcapi
82 tests of the Python C API, run via Lib/test/test_capi.py, and
83 implemented by module Modules/_testcapimodule.c
84pyexpat
85 Python wrapper for accelerated XML parsing, which incorporates stable
86 code from the Expat project: http://sourceforge.net/projects/expat/
87select
88 selectmodule.c
89unicodedata
90 large tables of Unicode data
91winsound
92 play sounds (typically .wav files) under Windows
93
94The following subprojects will generally NOT build out of the box. They
95wrap code Python doesn't control, and you'll need to download the base
96packages first and unpack them into siblings of PCbuilds's parent
97directory; for example, if your PCbuild is .......\dist\src\PCbuild\,
98unpack into new subdirectories of dist\.
99
100_tkinter
101 Python wrapper for the Tk windowing system. Requires building
102 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12.
103
104 Get source
105 ----------
106 In the dist directory, run
107 svn export http://svn.python.org/projects/external/tcl8.4.12
108 svn export http://svn.python.org/projects/external/tk8.4.12
109 svn export http://svn.python.org/projects/external/tix-8.4.0
110
111 Build Tcl first (done here w/ MSVC 7.1 on Windows XP)
112 ---------------
113 Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003
114 -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt"
115 to get a shell window with the correct environment settings
116 cd dist\tcl8.4.12\win
117 nmake -f makefile.vc
118 nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
119
120 XXX Should we compile with OPTS=threads?
121
122 Optional: run tests, via
123 nmake -f makefile.vc test
124
125 On WinXP Pro, wholly up to date as of 30-Aug-2004:
126 all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0
127 Sourced 129 Test Files.
128
129 Build Tk
130 --------
131 cd dist\tk8.4.12\win
132 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12
133 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install
134
135 XXX Should we compile with OPTS=threads?
136
137 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
138 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
139
140 Optional: run tests, via
141 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test
142
143 On WinXP Pro, wholly up to date as of 30-Aug-2004:
144 all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13
145 Sourced 91 Test Files.
146 Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test
147
148 Built Tix
149 ---------
150 cd dist\tix-8.4.0\win
151 nmake -f python.mak
152 nmake -f python.mak install
153
154bz2
155 Python wrapper for the libbz2 compression library. Homepage
156 http://sources.redhat.com/bzip2/
157 Download the source from the python.org copy into the dist
158 directory:
159
160 svn export http://svn.python.org/projects/external/bzip2-1.0.3
161
162 A custom pre-link step in the bz2 project settings should manage to
163 build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is
164 linked in PCbuild\.
165 However, the bz2 project is not smart enough to remove anything under
166 bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib
167 you need to clean up bzip2-1.0.3\ by hand.
168
169 The build step shouldn't yield any warnings or errors, and should end
170 by displaying 6 blocks each terminated with
171 FC: no differences encountered
172
173 All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python
174 project links in.
175
176
177_bsddb
178 To use the version of bsddb that Python is built with by default, invoke
179 (in the dist directory)
180
181 svn export http://svn.python.org/projects/external/db-4.4.20
182
183
184 Then open a VS.NET 2003 shell, and invoke:
185
186 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Release /project db_static
187
188 and do that a second time for a Debug build too:
189
190 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static
191
192 Alternatively, if you want to start with the original sources,
193 go to Sleepycat's download page:
194 http://www.sleepycat.com/downloads/releasehistorybdb.html
195
196 and download version 4.4.20.
197
198 With or without strong cryptography? You can choose either with or
199 without strong cryptography, as per the instructions below. By
200 default, Python is built and distributed WITHOUT strong crypto.
201
202 Unpack the sources; if you downloaded the non-crypto version, rename
203 the directory from db-4.4.20.NC to db-4.4.20.
204
205 Now apply any patches that apply to your version.
206
207 Open
208 dist\db-4.4.20\docs\index.html
209
210 and follow the "Windows->Building Berkeley DB with Visual C++ .NET"
211 instructions for building the Sleepycat
212 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
213 Build the "db_static" project, for "Release" mode.
214
215 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
216 is then enabled. Running in verbose mode may be helpful.
217
218 XXX The test_bsddb3 tests don't always pass, on Windows (according to
219 XXX me) or on Linux (according to Barry). (I had much better luck
220 XXX on Win2K than on Win98SE.) The common failure mode across platforms
221 XXX is
222 XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable
223 XXX to join the environment')
224 XXX
225 XXX and it appears timing-dependent. On Win2K I also saw this once:
226 XXX
227 XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ...
228 XXX Exception in thread reader 1:
229 XXX Traceback (most recent call last):
230 XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap
231 XXX self.run()
232 XXX File "C:\Code\python\lib\threading.py", line 399, in run
233 XXX apply(self.__target, self.__args, self.__kwargs)
234 XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in
235 XXX readerThread
236 XXX rec = c.next()
237 XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed
238 XXX to resolve a deadlock')
239 XXX
240 XXX I'm told that DBLockDeadlockError is expected at times. It
241 XXX doesn't cause a test to fail when it happens (exceptions in
242 XXX threads are invisible to unittest).
243
244 Building for Win64:
245 - open a VS.NET 2003 command prompt
246 - run the SDK setenv.cmd script, passing /RETAIL and the target
247 architecture (/SRV64 for Itanium, /X64 for AMD64)
248 - build BerkeleyDB with the solution configuration matching the
249 target ("Release IA64" for Itanium, "Release AMD64" for AMD64), e.g.
250 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build "Release AMD64" /project db_static /useenv
251
252_sqlite3
253 Python wrapper for SQLite library.
254
255 Get the source code through
256
257 svn export http://svn.python.org/projects/external/sqlite-source-3.3.4
258
259 To use the extension module in a Python build tree, copy sqlite3.dll into
260 the PCbuild folder.
261
262_ssl
263 Python wrapper for the secure sockets library.
264
265 Get the source code through
266
267 svn export http://svn.python.org/projects/external/openssl-0.9.8a
268
269 Alternatively, get the latest version from http://www.openssl.org.
270 You can (theoretically) use any version of OpenSSL you like - the
271 build process will automatically select the latest version.
272
273 You must also install ActivePerl from
274 http://www.activestate.com/Products/ActivePerl/
275 as this is used by the OpenSSL build process. Complain to them <wink>.
276
277 The MSVC project simply invokes PCBuild/build_ssl.py to perform
278 the build. This Python script locates and builds your OpenSSL
279 installation, then invokes a simple makefile to build the final .pyd.
280
281 build_ssl.py attempts to catch the most common errors (such as not
282 being able to find OpenSSL sources, or not being able to find a Perl
283 that works with OpenSSL) and give a reasonable error message.
284 If you have a problem that doesn't seem to be handled correctly
285 (eg, you know you have ActivePerl but we can't find it), please take
286 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
287 should be able to be run directly from the command-line.
288
289 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
290 this by hand.
291
Thomas Wouters4d70c3d2006-06-08 14:42:34 +0000292
293Building for AMD64
294------------------
295
Guido van Rossum360e4b82007-05-14 22:51:27 +0000296Select x64 as the destination platform.
Thomas Wouters4d70c3d2006-06-08 14:42:34 +0000297
Thomas Wouters4d70c3d2006-06-08 14:42:34 +0000298
299YOUR OWN EXTENSION DLLs
300-----------------------
301If you want to create your own extension module DLL, there's an example
302with easy-to-follow instructions in ../PC/example/; read the file
303readme.txt there first.
Guido van Rossum360e4b82007-05-14 22:51:27 +0000304Also, you can simply use Visual Studio to "Add new project to solution".
305Elect to create a win32 project, .dll, empty project.
306This will create a subdirectory with a .vcproj file in it. Now, You can
307simply copy most of another .vcproj, like _test_capi/_test_capi.vcproj over
308(you can't just copy and rename it, since the target will have a unique GUID.)
309At some point we want to be able to provide a template for creating a
310project.