Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 1 | Building Python using VC++ 9.0 |
| 2 | ------------------------------ |
| 3 | This directory is used to build Python for Win32 platforms, e.g. Windows |
| 4 | 2000, XP and Vista. It requires Microsoft Visual C++ 9.0 |
| 5 | (a.k.a. Visual Studio .NET 2008). |
| 6 | (For other Windows platforms and compilers, see ../PC/readme.txt.) |
| 7 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 8 | All you need to do is open the workspace "pcbuild.sln" in Visual Studio, |
| 9 | select the desired combination of configuration and platform and eventually |
| 10 | build the solution. Unless you are going to debug a problem in the core or |
| 11 | you are going to create an optimized build you want to select "Release" as |
| 12 | configuration. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 13 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 14 | The PCbuild9 directory is compatible with all versions of Visual Studio from |
| 15 | VS C++ Express Edition over the standard edition up to the professional |
| 16 | edition. However the express edition does support features like solution |
| 17 | folders or profile guided optimization (PGO). The missing bits and pieces |
| 18 | won't stop you from building Python. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 19 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 20 | The solution is configured to build the projects in the correct order. "Build |
| 21 | Solution" or F6 takes care of dependencies except for x64 builds. To make |
| 22 | cross compiling x64 builds on a 32bit OS possible the x64 builds require a |
| 23 | 32bit version of Python. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 24 | |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 25 | |
Christian Heimes | 3971f6b | 2007-11-30 19:18:08 +0000 | [diff] [blame^] | 26 | NOTE: |
| 27 | You probably don't want to build most of the other subprojects, unless |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 28 | you're building an entire Python distribution from scratch, or |
| 29 | specifically making changes to the subsystems they implement, or are |
| 30 | running a Python core buildbot test slave; see SUBPROJECTS below) |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 31 | |
| 32 | When using the Debug setting, the output files have a _d added to |
| 33 | their name: python30_d.dll, python_d.exe, parser_d.pyd, and so on. |
| 34 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 35 | The 32bit builds end up in the solution folder PCbuild9 while the x64 builds |
| 36 | land in the amd64 subfolder. The PGI and PGO builds for profile guided |
| 37 | optimization end up in their own folders, too. |
| 38 | |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 39 | SUBPROJECTS |
| 40 | ----------- |
| 41 | These subprojects should build out of the box. Subprojects other than the |
| 42 | main ones (pythoncore, python, pythonw) generally build a DLL (renamed to |
| 43 | .pyd) from a specific module so that users don't have to load the code |
| 44 | supporting that module unless they import the module. |
| 45 | |
| 46 | pythoncore |
| 47 | .dll and .lib |
| 48 | python |
| 49 | .exe |
| 50 | pythonw |
| 51 | pythonw.exe, a variant of python.exe that doesn't pop up a DOS box |
| 52 | _socket |
| 53 | socketmodule.c |
| 54 | _testcapi |
| 55 | tests of the Python C API, run via Lib/test/test_capi.py, and |
| 56 | implemented by module Modules/_testcapimodule.c |
| 57 | pyexpat |
| 58 | Python wrapper for accelerated XML parsing, which incorporates stable |
| 59 | code from the Expat project: http://sourceforge.net/projects/expat/ |
| 60 | select |
| 61 | selectmodule.c |
| 62 | unicodedata |
| 63 | large tables of Unicode data |
| 64 | winsound |
| 65 | play sounds (typically .wav files) under Windows |
| 66 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 67 | The following subprojects will generally NOT build out of the box. They |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 68 | wrap code Python doesn't control, and you'll need to download the base |
| 69 | packages first and unpack them into siblings of PCbuilds's parent |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 70 | directory; for example, if your PCbuild9 is ..\dist\py3k\PCbuild9\, |
| 71 | unpack into new subdirectories of ..\dist\. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 72 | |
| 73 | _tkinter |
| 74 | Python wrapper for the Tk windowing system. Requires building |
| 75 | Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 76 | |
| 77 | NOTE: The 64 build builds must land in tcltk64 instead of tcltk. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 78 | |
| 79 | Get source |
| 80 | ---------- |
| 81 | In the dist directory, run |
| 82 | svn export http://svn.python.org/projects/external/tcl8.4.12 |
| 83 | svn export http://svn.python.org/projects/external/tk8.4.12 |
| 84 | svn export http://svn.python.org/projects/external/tix-8.4.0 |
| 85 | |
| 86 | Build Tcl first (done here w/ MSVC 7.1 on Windows XP) |
| 87 | --------------- |
| 88 | Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 |
| 89 | -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" |
| 90 | to get a shell window with the correct environment settings |
| 91 | cd dist\tcl8.4.12\win |
| 92 | nmake -f makefile.vc |
| 93 | nmake -f makefile.vc INSTALLDIR=..\..\tcltk install |
| 94 | |
| 95 | XXX Should we compile with OPTS=threads? |
| 96 | |
| 97 | Optional: run tests, via |
| 98 | nmake -f makefile.vc test |
| 99 | |
| 100 | On WinXP Pro, wholly up to date as of 30-Aug-2004: |
| 101 | all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0 |
| 102 | Sourced 129 Test Files. |
| 103 | |
| 104 | Build Tk |
| 105 | -------- |
| 106 | cd dist\tk8.4.12\win |
| 107 | nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 |
| 108 | nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install |
| 109 | |
| 110 | XXX Should we compile with OPTS=threads? |
| 111 | |
| 112 | XXX Our installer copies a lot of stuff out of the Tcl/Tk install |
| 113 | XXX directory. Is all of that really needed for Python use of Tcl/Tk? |
| 114 | |
| 115 | Optional: run tests, via |
| 116 | nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test |
| 117 | |
| 118 | On WinXP Pro, wholly up to date as of 30-Aug-2004: |
| 119 | all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 |
| 120 | Sourced 91 Test Files. |
| 121 | Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test |
| 122 | |
| 123 | Built Tix |
| 124 | --------- |
| 125 | cd dist\tix-8.4.0\win |
| 126 | nmake -f python.mak |
| 127 | nmake -f python.mak install |
| 128 | |
| 129 | bz2 |
| 130 | Python wrapper for the libbz2 compression library. Homepage |
| 131 | http://sources.redhat.com/bzip2/ |
| 132 | Download the source from the python.org copy into the dist |
| 133 | directory: |
| 134 | |
| 135 | svn export http://svn.python.org/projects/external/bzip2-1.0.3 |
| 136 | |
| 137 | A custom pre-link step in the bz2 project settings should manage to |
| 138 | build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 139 | linked in PCbuild9\. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 140 | However, the bz2 project is not smart enough to remove anything under |
| 141 | bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib |
| 142 | you need to clean up bzip2-1.0.3\ by hand. |
| 143 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 144 | All of this managed to build libbz2.lib in |
| 145 | bzip2-1.0.3\$platform-$configuration\, which the Python project links in. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 146 | |
| 147 | |
| 148 | _bsddb |
| 149 | To use the version of bsddb that Python is built with by default, invoke |
| 150 | (in the dist directory) |
| 151 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 152 | svn export http://svn.python.org/projects/external/db-4.4.20 |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 153 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 154 | Next open the solution file db-4.4.20\build_win32\Berkeley_DB.sln with |
| 155 | Visual Studio and convert the projects to the new format. The standard |
| 156 | and professional version of VS 2008 builds the necessary libraries |
| 157 | in a pre-link step of _bsddb. However the express edition is missing |
| 158 | some pieces and you have to build the libs yourself. |
| 159 | |
| 160 | The _bsddb subprojects depends only on the db_static project of |
| 161 | Berkeley DB. You have to choose either "Release", "Release AMD64", "Debug" |
| 162 | or "Debug AMD64" as configuration. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 163 | |
| 164 | Alternatively, if you want to start with the original sources, |
| 165 | go to Sleepycat's download page: |
| 166 | http://www.sleepycat.com/downloads/releasehistorybdb.html |
| 167 | |
| 168 | and download version 4.4.20. |
| 169 | |
| 170 | With or without strong cryptography? You can choose either with or |
| 171 | without strong cryptography, as per the instructions below. By |
| 172 | default, Python is built and distributed WITHOUT strong crypto. |
| 173 | |
| 174 | Unpack the sources; if you downloaded the non-crypto version, rename |
| 175 | the directory from db-4.4.20.NC to db-4.4.20. |
| 176 | |
| 177 | Now apply any patches that apply to your version. |
| 178 | |
| 179 | Open |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 180 | db-4.4.20\docs\ref\build_win\intro.html |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 181 | |
| 182 | and follow the "Windows->Building Berkeley DB with Visual C++ .NET" |
| 183 | instructions for building the Sleepycat |
| 184 | software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. |
| 185 | Build the "db_static" project, for "Release" mode. |
| 186 | |
| 187 | To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py |
| 188 | is then enabled. Running in verbose mode may be helpful. |
| 189 | |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 190 | _sqlite3 |
| 191 | Python wrapper for SQLite library. |
| 192 | |
| 193 | Get the source code through |
| 194 | |
| 195 | svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 |
| 196 | |
| 197 | To use the extension module in a Python build tree, copy sqlite3.dll into |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 198 | the PCbuild folder. The source directory in svn also contains a .def file |
| 199 | from the binary release of sqlite3. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 200 | |
| 201 | _ssl |
| 202 | Python wrapper for the secure sockets library. |
| 203 | |
| 204 | Get the source code through |
| 205 | |
| 206 | svn export http://svn.python.org/projects/external/openssl-0.9.8g |
| 207 | |
| 208 | Alternatively, get the latest version from http://www.openssl.org. |
| 209 | You can (theoretically) use any version of OpenSSL you like - the |
| 210 | build process will automatically select the latest version. |
| 211 | |
Christian Heimes | 3971f6b | 2007-11-30 19:18:08 +0000 | [diff] [blame^] | 212 | You must install the NASM assembler from |
| 213 | http://www.kernel.org/pub/software/devel/nasm/binaries/win32/ |
| 214 | for x86 builds. Put nasmw.exe anywhere in your PATH. |
| 215 | |
| 216 | You can also install ActivePerl from |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 217 | http://www.activestate.com/Products/ActivePerl/ |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 218 | if you like to use the official sources instead of the files from |
| 219 | python's subversion repository. The svn version contains pre-build |
| 220 | makefiles and assembly files. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 221 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 222 | The build process makes sure that no patented algorithms are included. |
| 223 | For now RC5, MDC2 and IDEA are excluded from the build. You may have |
| 224 | to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process |
| 225 | complains about missing files or forbidden IDEA. Again the files provided |
| 226 | in the subversion repository are already fixed. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 227 | |
| 228 | The MSVC project simply invokes PCBuild/build_ssl.py to perform |
| 229 | the build. This Python script locates and builds your OpenSSL |
| 230 | installation, then invokes a simple makefile to build the final .pyd. |
| 231 | |
| 232 | build_ssl.py attempts to catch the most common errors (such as not |
| 233 | being able to find OpenSSL sources, or not being able to find a Perl |
| 234 | that works with OpenSSL) and give a reasonable error message. |
| 235 | If you have a problem that doesn't seem to be handled correctly |
| 236 | (eg, you know you have ActivePerl but we can't find it), please take |
| 237 | a peek at build_ssl.py and suggest patches. Note that build_ssl.py |
| 238 | should be able to be run directly from the command-line. |
| 239 | |
| 240 | build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do |
| 241 | this by hand. |
| 242 | |
| 243 | Building for Itanium |
| 244 | -------------------- |
| 245 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 246 | NOTE: |
| 247 | Official support for Itanium builds have been dropped from the build. Please |
| 248 | contact as and provide patches if you are interested in Itanium builds. |
| 249 | |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 250 | The project files support a ReleaseItanium configuration which creates |
| 251 | Win64/Itanium binaries. For this to work, you need to install the Platform |
| 252 | SDK, in particular the 64-bit support. This includes an Itanium compiler |
| 253 | (future releases of the SDK likely include an AMD64 compiler as well). |
| 254 | In addition, you need the Visual Studio plugin for external C compilers, |
| 255 | from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to |
| 256 | locate the proper target compiler, and convert compiler options |
| 257 | accordingly. The project files require atleast version 0.9. |
| 258 | |
| 259 | Building for AMD64 |
| 260 | ------------------ |
| 261 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 262 | The build process for AMD64 / x64 is very similar to standard builds. You just |
| 263 | have to set x64 as platform. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 264 | |
| 265 | Building Python Using the free MS Toolkit Compiler |
| 266 | -------------------------------------------------- |
| 267 | |
Christian Heimes | 3971f6b | 2007-11-30 19:18:08 +0000 | [diff] [blame^] | 268 | Microsoft has withdrawn the free MS Toolkit Compiler, so this can no longer |
| 269 | be considered a supported option. Instead you can use the free VS C++ Express |
| 270 | Edition. |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 271 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 272 | Profile Guided Optimization |
| 273 | --------------------------- |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 274 | |
Christian Heimes | 8b01140 | 2007-11-27 21:28:40 +0000 | [diff] [blame] | 275 | http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 276 | |
Christian Heimes | 3971f6b | 2007-11-30 19:18:08 +0000 | [diff] [blame^] | 277 | Static library |
| 278 | -------------- |
| 279 | |
| 280 | The solution has no configuration for static libraries. However it is easy |
| 281 | it build a static library instead of a DLL. You simply have to set the |
| 282 | "Configuration Type" to "Static Library (.lib)" and alter the preprocessor |
| 283 | macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to |
| 284 | change the "Runtime Library" from "Multi-threaded DLL (/MD)" to |
| 285 | "Multi-threaded (/MT)". |
| 286 | |
Christian Heimes | e8954f8 | 2007-11-22 11:21:16 +0000 | [diff] [blame] | 287 | YOUR OWN EXTENSION DLLs |
| 288 | ----------------------- |
| 289 | If you want to create your own extension module DLL, there's an example |
| 290 | with easy-to-follow instructions in ../PC/example/; read the file |
| 291 | readme.txt there first. |