| Tim Peters | a37722c | 2006-05-28 01:52:38 +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 | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 5 | (a.k.a. Visual Studio 2005).  There are two Platforms defined, Win32 | 
 | 6 | and x64. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 7 | (For other Windows platforms and compilers, see ../PC/readme.txt.) | 
 | 8 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 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 | 
 | 11 | the "Standard" toolbar"), and build the solution. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 12 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 13 | A .bat file, build.bat, is provided to simplify command line builds. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 14 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 15 | Some of the subprojects rely on external libraries and won't build | 
 | 16 | unless you have them installed. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 17 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 18 | Binary files go into PCBuild8\$(PlatformName)($ConfigurationName), | 
 | 19 | which will be something like Win32Debug, Win32Release, x64Release, etc. | 
| Kristján Valur Jónsson | 2c8851e | 2006-10-07 14:56:30 +0000 | [diff] [blame] | 20 |  | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 21 | When using the Debug setting, the output files have a _d added to | 
 | 22 | their name:  python25_d.dll, python_d.exe, parser_d.pyd, and so on. | 
 | 23 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +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. | 
| Kristján Valur Jónsson | 2c8851e | 2006-10-07 14:56:30 +0000 | [diff] [blame] | 43 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 44 | A .bat file, build_pgo.bat is included to automate this process | 
| Kristján Valur Jónsson | 2c8851e | 2006-10-07 14:56:30 +0000 | [diff] [blame] | 45 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 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 |  | 
| Kristján Valur Jónsson | 2c8851e | 2006-10-07 14:56:30 +0000 | [diff] [blame] | 65 |  | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 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 | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +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 | 
| Martin v. Löwis | 7303f70 | 2007-09-05 06:39:02 +0000 | [diff] [blame] | 93 |      | 
 | 94 | Note: Check the dependencies of subprojects when building a subproject.  You  | 
 | 95 | need to manually build each of the dependencies, in order, first.  A good  | 
 | 96 | example of this is the pythoncore subproject.  It is dependent on both the  | 
 | 97 | make_versioninfo and the make_buildinfo subprojects.  You can check the build  | 
 | 98 | order by right clicking on the project name, in the solution explorer, and  | 
 | 99 | selecting the project build order item. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 100 |  | 
 | 101 | The following subprojects will generally NOT build out of the box.  They | 
 | 102 | wrap code Python doesn't control, and you'll need to download the base | 
 | 103 | packages first and unpack them into siblings of PCbuilds's parent | 
 | 104 | directory; for example, if your PCbuild is  .......\dist\src\PCbuild\, | 
 | 105 | unpack 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 |  | 
 | 161 | bz2 | 
 | 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 Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 299 |  | 
 | 300 | Building for AMD64 | 
 | 301 | ------------------ | 
 | 302 |  | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 303 | Select x64 as the destination platform. | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 304 |  | 
| Tim Peters | a37722c | 2006-05-28 01:52:38 +0000 | [diff] [blame] | 305 |  | 
 | 306 | YOUR OWN EXTENSION DLLs | 
 | 307 | ----------------------- | 
 | 308 | If you want to create your own extension module DLL, there's an example | 
 | 309 | with easy-to-follow instructions in ../PC/example/; read the file | 
 | 310 | readme.txt there first. | 
| Kristján Valur Jónsson | 55d53f0 | 2007-05-02 15:55:14 +0000 | [diff] [blame] | 311 | Also, you can simply use Visual Studio to "Add new project to solution". | 
 | 312 | Elect to create a win32 project, .dll, empty project. | 
 | 313 | This will create a subdirectory with a .vcproj file in it.  Now, You can | 
 | 314 | simply 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.) | 
 | 316 | At some point we want to be able to provide a template for creating a | 
 | 317 | project. |