blob: f117bab2af4df7a741f8c0504beeb03485225c63 [file] [log] [blame]
Tim Petersa37722c2006-05-28 01:52:38 +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
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +00005(a.k.a. Visual Studio 2005). There are two Platforms defined, Win32
6and x64.
Tim Petersa37722c2006-05-28 01:52:38 +00007(For other Windows platforms and compilers, see ../PC/readme.txt.)
8
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +00009All you need to do is open the workspace "pcbuild.sln" in MSVC++, select
10the Debug or Release setting (using "Solution Configuration" from
11the "Standard" toolbar"), and build the solution.
Tim Petersa37722c2006-05-28 01:52:38 +000012
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +000013A .bat file, build.bat, is provided to simplify command line builds.
Tim Petersa37722c2006-05-28 01:52:38 +000014
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +000015Some of the subprojects rely on external libraries and won't build
16unless you have them installed.
Tim Petersa37722c2006-05-28 01:52:38 +000017
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +000018Binary files go into PCBuild8\$(PlatformName)($ConfigurationName),
19which will be something like Win32Debug, Win32Release, x64Release, etc.
Kristján Valur Jónsson2c8851e2006-10-07 14:56:30 +000020
Tim Petersa37722c2006-05-28 01:52:38 +000021When using the Debug setting, the output files have a _d added to
22their name: python25_d.dll, python_d.exe, parser_d.pyd, and so on.
23
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +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.
Kristján Valur Jónsson2c8851e2006-10-07 14:56:30 +000043
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +000044A .bat file, build_pgo.bat is included to automate this process
Kristján Valur Jónsson2c8851e2006-10-07 14:56:30 +000045
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +000046You 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
Kristján Valur Jónsson2c8851e2006-10-07 14:56:30 +000065
Tim Petersa37722c2006-05-28 01:52:38 +000066SUBPROJECTS
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
Tim Petersa37722c2006-05-28 01:52:38 +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
Martin v. Löwis7303f702007-09-05 06:39:02 +000093
94Note: Check the dependencies of subprojects when building a subproject. You
95need to manually build each of the dependencies, in order, first. A good
96example of this is the pythoncore subproject. It is dependent on both the
97make_versioninfo and the make_buildinfo subprojects. You can check the build
98order by right clicking on the project name, in the solution explorer, and
99selecting the project build order item.
Tim Petersa37722c2006-05-28 01:52:38 +0000100
101The following subprojects will generally NOT build out of the box. They
102wrap code Python doesn't control, and you'll need to download the base
103packages first and unpack them into siblings of PCbuilds's parent
104directory; for example, if your PCbuild is .......\dist\src\PCbuild\,
105unpack into new subdirectories of dist\.
106
107_tkinter
108 Python wrapper for the Tk windowing system. Requires building
109 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12.
110
111 Get source
112 ----------
113 In the dist directory, run
114 svn export http://svn.python.org/projects/external/tcl8.4.12
115 svn export http://svn.python.org/projects/external/tk8.4.12
116 svn export http://svn.python.org/projects/external/tix-8.4.0
117
118 Build Tcl first (done here w/ MSVC 7.1 on Windows XP)
119 ---------------
120 Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003
121 -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt"
122 to get a shell window with the correct environment settings
123 cd dist\tcl8.4.12\win
124 nmake -f makefile.vc
125 nmake -f makefile.vc INSTALLDIR=..\..\tcltk install
126
127 XXX Should we compile with OPTS=threads?
128
129 Optional: run tests, via
130 nmake -f makefile.vc test
131
132 On WinXP Pro, wholly up to date as of 30-Aug-2004:
133 all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0
134 Sourced 129 Test Files.
135
136 Build Tk
137 --------
138 cd dist\tk8.4.12\win
139 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12
140 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install
141
142 XXX Should we compile with OPTS=threads?
143
144 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
145 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
146
147 Optional: run tests, via
148 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test
149
150 On WinXP Pro, wholly up to date as of 30-Aug-2004:
151 all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13
152 Sourced 91 Test Files.
153 Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test
154
155 Built Tix
156 ---------
157 cd dist\tix-8.4.0\win
158 nmake -f python.mak
159 nmake -f python.mak install
160
161bz2
162 Python wrapper for the libbz2 compression library. Homepage
163 http://sources.redhat.com/bzip2/
164 Download the source from the python.org copy into the dist
165 directory:
166
167 svn export http://svn.python.org/projects/external/bzip2-1.0.3
168
169 A custom pre-link step in the bz2 project settings should manage to
170 build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is
171 linked in PCbuild\.
172 However, the bz2 project is not smart enough to remove anything under
173 bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib
174 you need to clean up bzip2-1.0.3\ by hand.
175
176 The build step shouldn't yield any warnings or errors, and should end
177 by displaying 6 blocks each terminated with
178 FC: no differences encountered
179
180 All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python
181 project links in.
182
183
184_bsddb
185 To use the version of bsddb that Python is built with by default, invoke
186 (in the dist directory)
187
188 svn export http://svn.python.org/projects/external/db-4.4.20
189
190
191 Then open a VS.NET 2003 shell, and invoke:
192
193 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Release /project db_static
194
195 and do that a second time for a Debug build too:
196
197 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build Debug /project db_static
198
199 Alternatively, if you want to start with the original sources,
200 go to Sleepycat's download page:
201 http://www.sleepycat.com/downloads/releasehistorybdb.html
202
203 and download version 4.4.20.
204
205 With or without strong cryptography? You can choose either with or
206 without strong cryptography, as per the instructions below. By
207 default, Python is built and distributed WITHOUT strong crypto.
208
209 Unpack the sources; if you downloaded the non-crypto version, rename
210 the directory from db-4.4.20.NC to db-4.4.20.
211
212 Now apply any patches that apply to your version.
213
214 Open
215 dist\db-4.4.20\docs\index.html
216
217 and follow the "Windows->Building Berkeley DB with Visual C++ .NET"
218 instructions for building the Sleepycat
219 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
220 Build the "db_static" project, for "Release" mode.
221
222 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
223 is then enabled. Running in verbose mode may be helpful.
224
225 XXX The test_bsddb3 tests don't always pass, on Windows (according to
226 XXX me) or on Linux (according to Barry). (I had much better luck
227 XXX on Win2K than on Win98SE.) The common failure mode across platforms
228 XXX is
229 XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable
230 XXX to join the environment')
231 XXX
232 XXX and it appears timing-dependent. On Win2K I also saw this once:
233 XXX
234 XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ...
235 XXX Exception in thread reader 1:
236 XXX Traceback (most recent call last):
237 XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap
238 XXX self.run()
239 XXX File "C:\Code\python\lib\threading.py", line 399, in run
240 XXX apply(self.__target, self.__args, self.__kwargs)
241 XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in
242 XXX readerThread
243 XXX rec = c.next()
244 XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed
245 XXX to resolve a deadlock')
246 XXX
247 XXX I'm told that DBLockDeadlockError is expected at times. It
248 XXX doesn't cause a test to fail when it happens (exceptions in
249 XXX threads are invisible to unittest).
250
251 Building for Win64:
252 - open a VS.NET 2003 command prompt
253 - run the SDK setenv.cmd script, passing /RETAIL and the target
254 architecture (/SRV64 for Itanium, /X64 for AMD64)
255 - build BerkeleyDB with the solution configuration matching the
256 target ("Release IA64" for Itanium, "Release AMD64" for AMD64), e.g.
257 devenv db-4.4.20\build_win32\Berkeley_DB.sln /build "Release AMD64" /project db_static /useenv
258
259_sqlite3
260 Python wrapper for SQLite library.
261
262 Get the source code through
263
264 svn export http://svn.python.org/projects/external/sqlite-source-3.3.4
265
266 To use the extension module in a Python build tree, copy sqlite3.dll into
267 the PCbuild folder.
268
269_ssl
270 Python wrapper for the secure sockets library.
271
272 Get the source code through
273
274 svn export http://svn.python.org/projects/external/openssl-0.9.8a
275
276 Alternatively, get the latest version from http://www.openssl.org.
277 You can (theoretically) use any version of OpenSSL you like - the
278 build process will automatically select the latest version.
279
280 You must also install ActivePerl from
281 http://www.activestate.com/Products/ActivePerl/
282 as this is used by the OpenSSL build process. Complain to them <wink>.
283
284 The MSVC project simply invokes PCBuild/build_ssl.py to perform
285 the build. This Python script locates and builds your OpenSSL
286 installation, then invokes a simple makefile to build the final .pyd.
287
288 build_ssl.py attempts to catch the most common errors (such as not
289 being able to find OpenSSL sources, or not being able to find a Perl
290 that works with OpenSSL) and give a reasonable error message.
291 If you have a problem that doesn't seem to be handled correctly
292 (eg, you know you have ActivePerl but we can't find it), please take
293 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
294 should be able to be run directly from the command-line.
295
296 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
297 this by hand.
298
Tim Petersa37722c2006-05-28 01:52:38 +0000299
300Building for AMD64
301------------------
302
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +0000303Select x64 as the destination platform.
Tim Petersa37722c2006-05-28 01:52:38 +0000304
Tim Petersa37722c2006-05-28 01:52:38 +0000305
306YOUR OWN EXTENSION DLLs
307-----------------------
308If you want to create your own extension module DLL, there's an example
309with easy-to-follow instructions in ../PC/example/; read the file
310readme.txt there first.
Kristján Valur Jónsson55d53f02007-05-02 15:55:14 +0000311Also, you can simply use Visual Studio to "Add new project to solution".
312Elect to create a win32 project, .dll, empty project.
313This will create a subdirectory with a .vcproj file in it. Now, You can
314simply copy most of another .vcproj, like _test_capi/_test_capi.vcproj over
315(you can't just copy and rename it, since the target will have a unique GUID.)
316At some point we want to be able to provide a template for creating a
317project.