blob: b7e1f32a7c3753c01106823e4eb2cfd451bc66ac [file] [log] [blame]
Tim Peters4b5fb072000-07-01 00:03:43 +00001Building Python using VC++ 6.0 or 5.0
Guido van Rossuma29b3602000-03-29 01:51:37 +00002-------------------------------------
Tim Peters4b5fb072000-07-01 00:03:43 +00003This directory is used to build Python for Win32 platforms, e.g. Windows
495, 98 and NT. It requires Microsoft Visual C++ 6.x or 5.x.
Guido van Rossum15b239f1998-05-26 14:16:23 +00005(For other Windows platforms and compilers, see ../PC/readme.txt.)
6
Tim Peters4b5fb072000-07-01 00:03:43 +00007All you need to do is open the workspace "pcbuild.dsw" in MSVC++, select
8the Debug or Release setting (using Build -> Set Active Configuration...),
9and build the projects.
Guido van Rossum15b239f1998-05-26 14:16:23 +000010
Tim Petersbefc97c2001-01-18 19:01:39 +000011The proper order to build subprojects:
Guido van Rossum15b239f1998-05-26 14:16:23 +000012
Tim Peters97c96402001-01-17 23:23:13 +0000131) pythoncore (this builds the main Python DLL and library files,
Tim Petersbefc97c2001-01-18 19:01:39 +000014 python21.{dll, lib} in Release mode)
15 NOTE: in previous releases, this subproject was
16 named after the release number, e.g. python20.
Guido van Rossum15b239f1998-05-26 14:16:23 +000017
Tim Petersbefc97c2001-01-18 19:01:39 +0000182) python (this builds the main Python executable,
19 python.exe in Release mode)
Tim Peters4b5fb072000-07-01 00:03:43 +000020
213) the other subprojects, as desired or needed (note: you probably don't
22 want to build most of the other subprojects, unless you're building an
23 entire Python distribution from scratch, or specifically making changes
24 to the subsystems they implement; see SUBPROJECTS below)
Guido van Rossum15b239f1998-05-26 14:16:23 +000025
26When using the Debug setting, the output files have a _d added to
Tim Peters97c96402001-01-17 23:23:13 +000027their name: python21_d.dll, python_d.exe, parser_d.pyd, and so on.
Guido van Rossume79cf321998-07-07 22:35:03 +000028
Tim Peters4b5fb072000-07-01 00:03:43 +000029SUBPROJECTS
30-----------
Tim Peters610a8272000-07-01 02:51:23 +000031These subprojects should build out of the box. Subprojects other than the
Tim Petersbefc97c2001-01-18 19:01:39 +000032main ones (pythoncore, python, pythonw) generally build a DLL (renamed to
Tim Peters610a8272000-07-01 02:51:23 +000033.pyd) from a specific module so that users don't have to load the code
Tim Peters4b5fb072000-07-01 00:03:43 +000034supporting that module unless they import the module.
Guido van Rossume79cf321998-07-07 22:35:03 +000035
Tim Peters97c96402001-01-17 23:23:13 +000036pythoncore
Tim Peters4b5fb072000-07-01 00:03:43 +000037 .dll and .lib
38python
39 .exe
40pythonw
41 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box
Tim Peters0d7ce4e2003-03-21 01:55:41 +000042_csv
43 C support for the comma-separated values module
Tim Peters4b5fb072000-07-01 00:03:43 +000044_socket
45 socketmodule.c
46_sre
47 Unicode-aware regular expression engine
Tim Petersb16c56f2001-02-02 21:24:51 +000048_symtable
49 the _symtable module, symtablemodule.c
Tim Petersd66595f2001-02-04 03:09:53 +000050_testcapi
Tim Petersb16c56f2001-02-02 21:24:51 +000051 tests of the Python C API, run via Lib/test/test_capi.py, and
Tim Petersd66595f2001-02-04 03:09:53 +000052 implemented by module Modules/_testcapimodule.c
Tim Peters2a799bf2002-12-16 20:18:38 +000053datetime
54 datetimemodule.c
Tim Peters4b5fb072000-07-01 00:03:43 +000055mmap
56 mmapmodule.c
57parser
58 the parser module
Tim Petersb012a152002-02-13 23:56:46 +000059pyexpat
60 Python wrapper for accelerated XML parsing, which incorporates stable
61 code from the Expat project: http://sourceforge.net/projects/expat/
Tim Peters4b5fb072000-07-01 00:03:43 +000062select
63 selectmodule.c
Tim Peters19f52c22001-01-24 10:07:22 +000064unicodedata
Tim Peters4b5fb072000-07-01 00:03:43 +000065 large tables of Unicode data
66winreg
67 Windows registry API
68winsound
69 play sounds (typically .wav files) under Windows
70
71The following subprojects will generally NOT build out of the box. They
72wrap code Python doesn't control, and you'll need to download the base
Tim Petersaff12842000-08-25 06:52:44 +000073packages first and unpack them into siblings of PCbuilds's parent
74directory; for example, if your PCbuild is .......\dist\src\PCbuild\,
75unpack into new subdirectories of dist\.
Tim Peters4b5fb072000-07-01 00:03:43 +000076
77_tkinter
Tim Peters077736b2002-11-14 23:24:40 +000078 Python wrapper for the Tk windowing system. Requires building
Tim Petersfaa697a2003-06-22 01:42:20 +000079 Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.3:
Tim Peters077736b2002-11-14 23:24:40 +000080
81 Get source
82 ----------
83 Go to
84 http://prdownloads.sourceforge.net/tcl/
85 and download
Tim Petersfaa697a2003-06-22 01:42:20 +000086 tcl843-src.zip
87 tk843-src.zip
Tim Peters077736b2002-11-14 23:24:40 +000088 Unzip into
Tim Petersfaa697a2003-06-22 01:42:20 +000089 dist\tcl8.4.3\
90 dist\tk8.4.3\
Tim Peters077736b2002-11-14 23:24:40 +000091 respectively.
92
Tim Petersfaa697a2003-06-22 01:42:20 +000093 Build Tcl first (done here w/ MSVC 6 on Win98SE)
Tim Peters6c629952002-11-15 18:36:11 +000094 ---------------
Tim Petersfaa697a2003-06-22 01:42:20 +000095 cd dist\tcl8.4.3\win
Tim Peters077736b2002-11-14 23:24:40 +000096 run vcvars32.bat [necessary even on Win2K]
97 nmake -f makefile.vc
98 nmake -f makefile.vc INSTALLDIR=..\..\tcl84 install
99
100 XXX Should we compile with OPTS=threads?
101
102 XXX Some tests failed in "nmake -f makefile.vc test".
Tim Petersfaa697a2003-06-22 01:42:20 +0000103 XXX all.tcl: Total 10480 Passed 9743 Skipped 719 Failed 18
Tim Peters8f6c7c52003-06-27 15:49:35 +0000104 XXX
105 XXX That was on Win98SE. On Win2K:
106 XXX all.tcl Total 10480 Passed 9781 Skipped 698 Failed 1
Tim Peters077736b2002-11-14 23:24:40 +0000107
Tim Peters077736b2002-11-14 23:24:40 +0000108 Build Tk
Tim Peters6c629952002-11-15 18:36:11 +0000109 --------
Tim Petersfaa697a2003-06-22 01:42:20 +0000110 cd dist\tk8.4.3\win
111 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3
112 nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 INSTALLDIR=..\..\tcl84 install
Tim Peters077736b2002-11-14 23:24:40 +0000113
114 XXX Should we compile with OPTS=threads?
115
Tim Petersfaa697a2003-06-22 01:42:20 +0000116 XXX I have no idea whether "nmake -f makefile.vc test" passed or
117 XXX failed. It popped up tons of little windows, and did lots of
118 XXX stuff, and nothing blew up.
Tim Peters077736b2002-11-14 23:24:40 +0000119
120 XXX Our installer copies a lot of stuff out of the Tcl/Tk install
121 XXX directory. Is all of that really needed for Python use of Tcl/Tk?
122
Tim Petersa406b582002-11-19 17:38:27 +0000123 Make sure the installer matches
124 -------------------------------
125 Ensure that the Wise compiler vrbl _TCLDIR_ is set to the name of
126 the common Tcl/Tk installation directory (tcl84 for the instructions
127 above). This is needed so the installer can copy various Tcl/Tk
128 files into the Python distribution.
129
Tim Peters4b5fb072000-07-01 00:03:43 +0000130
131zlib
Tim Petersee826f82001-01-31 19:39:44 +0000132 Python wrapper for the zlib compression library. Get the source code
Tim Peters6077f642002-03-13 21:51:55 +0000133 for version 1.1.4 from a convenient mirror at:
134 http://www.gzip.org/zlib/
135 Unpack into dist\zlib-1.1.4.
Tim Petersee826f82001-01-31 19:39:44 +0000136 A custom pre-link step in the zlib project settings should manage to
Tim Peters6077f642002-03-13 21:51:55 +0000137 build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is
Tim Petersee826f82001-01-31 19:39:44 +0000138 linked in PCbuild\.
139 However, the zlib project is not smart enough to remove anything under
Tim Peters6077f642002-03-13 21:51:55 +0000140 zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib
141 you need to clean up zlib-1.1.4\ by hand.
Tim Peters4b5fb072000-07-01 00:03:43 +0000142
Tim Petersb0ead4e2002-11-09 04:48:58 +0000143bz2
144 Python wrapper for the libbz2 compression library. Homepage
145 http://sources.redhat.com/bzip2/
146 Download the source tarball, bzip2-1.0.2.tar.gz.
Tim Peters077736b2002-11-14 23:24:40 +0000147 Unpack into dist\bzip2-1.0.2. WARNING: If you're using WinZip, you
Tim Petersb0ead4e2002-11-09 04:48:58 +0000148 must disable its "TAR file smart CR/LF conversion" feature (under
149 Options -> Configuration -> Miscellaneous -> Other) for the duration.
Tim Peters077736b2002-11-14 23:24:40 +0000150
Tim Petersb0ead4e2002-11-09 04:48:58 +0000151 Don't bother trying to use libbz2.dsp with MSVC. After 10 minutes
152 of fiddling, I couldn't get it to work. Perhaps it works with
153 MSVC 5 (I used MSVC 6). It's better to run the by-hand makefile
Tim Peters077736b2002-11-14 23:24:40 +0000154 anyway, because it runs a helpful test step at the end.
155
Tim Petersb0ead4e2002-11-09 04:48:58 +0000156 cd into dist\bzip2-1.0.2, and run
157 nmake -f makefile.msc
158 [Note that if you're running Win9X, you'll need to run vcvars32.bat
159 before running nmake (this batch file is in your MSVC installation).
160 TODO: make this work like zlib (in particular, MSVC runs the prelink
161 step in an enviroment that already has the correct envars set up).
162 ]
Tim Peters077736b2002-11-14 23:24:40 +0000163 The make step shouldn't yield any warnings or errors, and should end
Tim Petersb0ead4e2002-11-09 04:48:58 +0000164 by displaying 6 blocks each terminated with
165 FC: no differences encountered
166 If FC finds differences, see the warning abou WinZip above (when I
167 first tried it, sample3.ref failed due to CRLF conversion).
Tim Peters077736b2002-11-14 23:24:40 +0000168
Tim Petersb0ead4e2002-11-09 04:48:58 +0000169 All of this managed to build bzip2-1.0.2\libbz2.lib, which the Python
170 project links in.
171
172
Tim Peters78e35f92002-11-22 20:00:34 +0000173_bsddb
Tim Peters00640262003-01-24 15:31:31 +0000174 Go to Sleepycat's download page:
175 http://www.sleepycat.com/download/
Tim Petersb0ead4e2002-11-09 04:48:58 +0000176
Tim Peters00640262003-01-24 15:31:31 +0000177 and download version 4.1.25. The file name is db-4.1.25.NC.zip.
178 XXX with or without strong cryptography? I picked "without".
Tim Peters78e35f92002-11-22 20:00:34 +0000179
Tim Peters00640262003-01-24 15:31:31 +0000180 Unpack into
181 dist\db-4.1.25
Tim Peters78e35f92002-11-22 20:00:34 +0000182
Tim Peters00640262003-01-24 15:31:31 +0000183 [If using WinZip to unpack the db-4.1.25.NC distro, that requires
184 renaming the directory (to remove ".NC") after unpacking.
185 ]
186
187 Open
188 dist\db-4.1.25\docs\index.html
189
190 and follow the Windows instructions for building the Sleepycat
191 software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory.
192 Build the Release version ("build_all -- Win32 Release").
193
194 XXX We're actually linking against Release_static\libdb41s.lib.
Tim Peters84c7a3f2002-11-23 18:48:06 +0000195 XXX This yields the following warnings:
196"""
197Compiling...
198_bsddb.c
199Linking...
200 Creating library ./_bsddb.lib and object ./_bsddb.exp
201LINK : warning LNK4049: locally defined symbol "_malloc" imported
202LINK : warning LNK4049: locally defined symbol "_free" imported
203LINK : warning LNK4049: locally defined symbol "_fclose" imported
204LINK : warning LNK4049: locally defined symbol "_fopen" imported
205_bsddb.pyd - 0 error(s), 4 warning(s)
206"""
207 XXX This isn't encouraging, but I don't know what to do about it.
Tim Peters78e35f92002-11-22 20:00:34 +0000208
Tim Peters00640262003-01-24 15:31:31 +0000209 To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py
210 is then enabled. Running in verbose mode may be helpful.
211
212 XXX The test_bsddb3 tests don't always pass, on Windows (according to
213 XXX me) or on Linux (according to Barry). I had much better luck
214 XXX on Win2K than on Win98SE. The common failure mode across platforms
215 XXX is
216 XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable
217 XXX to join the environment')
218 XXX
219 XXX and it appears timing-dependent. On Win2K I also saw this once:
220 XXX
221 XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ...
222 XXX Exception in thread reader 1:
223 XXX Traceback (most recent call last):
224 XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap
225 XXX self.run()
226 XXX File "C:\Code\python\lib\threading.py", line 399, in run
227 XXX apply(self.__target, self.__args, self.__kwargs)
228 XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in
229 XXX readerThread
230 XXX rec = c.next()
231 XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed
232 XXX to resolve a deadlock')
Tim Petersad8605d2003-01-29 00:38:42 +0000233 XXX
234 XXX I'm told that DBLockDeadlockError is expected at times. It
235 XXX doesn't cause a test to fail when it happens (exceptions in
236 XXX threads are invisible to unittest).
Tim Peters00640262003-01-24 15:31:31 +0000237
Tim Peterse8bcb252002-12-04 02:39:52 +0000238
Mark Hammondf229f9f2002-12-03 05:47:26 +0000239_ssl
Tim Peterse8bcb252002-12-04 02:39:52 +0000240 Python wrapper for the secure sockets library.
Tim Peters4b5fb072000-07-01 00:03:43 +0000241
Mark Hammondf229f9f2002-12-03 05:47:26 +0000242 Get the latest source code for OpenSSL from
243 http://www.openssl.org
244
Tim Peterse8bcb252002-12-04 02:39:52 +0000245 You (probably) don't want the "engine" code. For example, get
246 openssl-0.9.6g.tar.gz
247 not
248 openssl-engine-0.9.6g.tar.gz
249
Mark Hammondf229f9f2002-12-03 05:47:26 +0000250 Unpack into the "dist" directory, retaining the folder name from
251 the archive - for example, the latest stable OpenSSL will install as
252 dist/openssl-0.9.6g
253
254 You can (theoretically) use any version of OpenSSL you like - the
255 build process will automatically select the latest version.
256
257 You must also install ActivePerl from
258 http://www.activestate.com/Products/ActivePerl/
Tim Peterse8bcb252002-12-04 02:39:52 +0000259 as this is used by the OpenSSL build process. Complain to them <wink>.
Mark Hammondf229f9f2002-12-03 05:47:26 +0000260
261 The MSVC project simply invokes PCBuild/build_ssl.py to perform
Tim Peterse8bcb252002-12-04 02:39:52 +0000262 the build. This Python script locates and builds your OpenSSL
Mark Hammondf229f9f2002-12-03 05:47:26 +0000263 installation, then invokes a simple makefile to build the final .pyd.
264
Tim Peters6ee68d22002-12-04 03:16:37 +0000265 Win9x users: see "Win9x note" below.
266
Mark Hammondf229f9f2002-12-03 05:47:26 +0000267 build_ssl.py attempts to catch the most common errors (such as not
268 being able to find OpenSSL sources, or not being able to find a Perl
269 that works with OpenSSL) and give a reasonable error message.
270 If you have a problem that doesn't seem to be handled correctly
271 (eg, you know you have ActivePerl but we can't find it), please take
272 a peek at build_ssl.py and suggest patches. Note that build_ssl.py
273 should be able to be run directly from the command-line.
274
Tim Peterse8bcb252002-12-04 02:39:52 +0000275 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do
276 this by hand.
Tim Peters4b5fb072000-07-01 00:03:43 +0000277
Tim Peters6ee68d22002-12-04 03:16:37 +0000278 Win9x note: If, near the start of the build process, you see
279 something like
280
281 C:\Code\openssl-0.9.6g>set OPTS=no-asm
282 Out of environment space
283
Tim Peters21d77f52002-12-04 04:00:12 +0000284 then you're in trouble, and will probably also see these errors near
Tim Peters6ee68d22002-12-04 03:16:37 +0000285 the end of the process:
286
287 NMAKE : fatal error U1073: don't know how to make
288 'crypto\md5\asm\m5_win32.asm'
289 Stop.
290 NMAKE : fatal error U1073: don't know how to make
291 'C:\Code\openssl-0.9.6g/out32/libeay32.lib'
292 Stop.
293
294 You need more environment space. Win9x only has room for 256 bytes
295 by default, and especially after installing ActivePerl (which fiddles
296 the PATH envar), you're likely to run out. KB Q230205
297
298 http://support.microsoft.com/default.aspx?scid=KB;en-us;q230205
299
300 explains how to edit CONFIG.SYS to cure this.
301
302
Tim Petersf9a4a6e2000-07-01 20:38:27 +0000303YOUR OWN EXTENSION DLLs
Tim Peters4b5fb072000-07-01 00:03:43 +0000304-----------------------
305If you want to create your own extension module DLL, there's an example
306with easy-to-follow instructions in ../PC/example/; read the file
307readme.txt there first.