Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 1 | Building Python using VC++ 8.0 |
| 2 | ------------------------------------- |
| 3 | This directory is used to build Python for Win32 platforms, e.g. Windows |
| 4 | 95, 98 and NT. It requires Microsoft Visual C++ 8.0 |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 5 | (a.k.a. Visual Studio 2005). There are two Platforms defined, Win32 |
| 6 | and x64. |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 7 | (For other Windows platforms and compilers, see ../PC/readme.txt.) |
| 8 | |
| 9 | All you need to do is open the workspace "pcbuild.sln" in MSVC++, select |
| 10 | the Debug or Release setting (using "Solution Configuration" from |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 11 | the "Standard" toolbar"), and build the solution. |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 12 | |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 13 | A .bat file, build.bat, is provided to simplify command line builds. |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 14 | |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 15 | Some of the subprojects rely on external libraries and won't build |
| 16 | unless you have them installed. |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 17 | |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 18 | Binary files go into PCBuild8\$(PlatformName)($ConfigurationName), |
| 19 | which will be something like Win32Debug, Win32Release, x64Release, etc. |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 20 | |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 21 | When using the Debug setting, the output files have a _d added to |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 22 | their name: python26_d.dll, python_d.exe, parser_d.pyd, and so on. |
| 23 | |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 24 | PROFILER GUIDED OPTIMIZATION |
| 25 | ---------------------------- |
| 26 | There are two special solution configurations for Profiler Guided |
| 27 | Optimization. Careful use of this has been shown to yield more than |
| 28 | 10% extra speed. |
| 29 | 1) Build the PGInstrument solution configuration. This will yield |
| 30 | binaries in the win32PGO or x64PGO folders. (You may want do start |
| 31 | by erasing any .pgc files there, present from earlier runs.) |
| 32 | 2) Instrument the binaries. Do this by for example running the test |
| 33 | suite: win32PGO\python.exe ..\lib\test\regrtest.py. This will excercise |
| 34 | python thoroughly. |
| 35 | 3) Build the PGUpdate solution configuration (You may need to ask it |
| 36 | to rebuild.) This will incorporate the information gathered in step 2 |
| 37 | and produce new binaries in the same win32PGO or x64pPGO folders. |
| 38 | 4) (optional) You can continue to build the PGUpdate configuration as |
| 39 | you work on python. It will continue to use the data from step 2, even |
| 40 | if you add or modify files as part of your work. Thus, it makes sense to |
| 41 | run steps 1 and 2 maybe once a week, and then use step 3) for all regular |
| 42 | work. |
| 43 | |
| 44 | A .bat file, build_pgo.bat is included to automate this process |
| 45 | |
| 46 | You can convince yourself of the benefits of the PGO by comparing the |
| 47 | results of the python testsuite with the regular Release build. |
| 48 | |
| 49 | |
| 50 | C RUNTIME |
| 51 | --------- |
| 52 | Visual Studio 2005 uses version 8 of the C runtime. The executables are |
| 53 | linked to a CRT "side by side" assembly which must be present on the target |
| 54 | machine. This is avalible under the VC/Redist folder of your visual studio |
| 55 | distribution. Note that ServicePack1 of Visual Studio 2005 has a different |
| 56 | version than the original. On XP and later operating systems that support |
| 57 | side-by-side assemblies it is not enough to have the msvcrt80.dll present, |
| 58 | it has to be there as a whole assembly, that is, a folder with the .dll |
| 59 | and a .manifest. Also, a check is made for the correct version. |
| 60 | Therefore, one should distribute this assembly with the dlls, and keep |
| 61 | it in the same directory. For compatibility with older systems, one should |
| 62 | also set the PATH to this directory so that the dll can be found. |
| 63 | For more info, see the Readme in the VC/Redist folder. |
| 64 | |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 65 | |
| 66 | SUBPROJECTS |
| 67 | ----------- |
| 68 | These subprojects should build out of the box. Subprojects other than the |
| 69 | main 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 |
| 71 | supporting that module unless they import the module. |
| 72 | |
| 73 | pythoncore |
| 74 | .dll and .lib |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 75 | python |
| 76 | .exe |
| 77 | pythonw |
| 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 |
| 84 | pyexpat |
| 85 | Python wrapper for accelerated XML parsing, which incorporates stable |
| 86 | code from the Expat project: http://sourceforge.net/projects/expat/ |
| 87 | select |
| 88 | selectmodule.c |
| 89 | unicodedata |
| 90 | large tables of Unicode data |
| 91 | winsound |
| 92 | play sounds (typically .wav files) under Windows |
| 93 | |
| 94 | The following subprojects will generally NOT build out of the box. They |
| 95 | wrap code Python doesn't control, and you'll need to download the base |
| 96 | packages first and unpack them into siblings of PCbuilds's parent |
| 97 | directory; for example, if your PCbuild is .......\dist\src\PCbuild\, |
| 98 | unpack 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 | |
| 154 | bz2 |
| 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 Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 292 | |
| 293 | Building for AMD64 |
| 294 | ------------------ |
| 295 | |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 296 | Select x64 as the destination platform. |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 297 | |
Thomas Wouters | 4d70c3d | 2006-06-08 14:42:34 +0000 | [diff] [blame] | 298 | |
| 299 | YOUR OWN EXTENSION DLLs |
| 300 | ----------------------- |
| 301 | If you want to create your own extension module DLL, there's an example |
| 302 | with easy-to-follow instructions in ../PC/example/; read the file |
| 303 | readme.txt there first. |
Guido van Rossum | 360e4b8 | 2007-05-14 22:51:27 +0000 | [diff] [blame] | 304 | Also, you can simply use Visual Studio to "Add new project to solution". |
| 305 | Elect to create a win32 project, .dll, empty project. |
| 306 | This will create a subdirectory with a .vcproj file in it. Now, You can |
| 307 | simply 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.) |
| 309 | At some point we want to be able to provide a template for creating a |
| 310 | project. |