1Building Python using VC++ 9.0 2------------------------------ 3 4This directory is used to build Python for Win32 and x64 platforms, e.g. 5Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit 6debug and release executables, Microsoft Visual C++ 2008 Express Edition is 7required at the very least. In order to build 64-bit debug and release 8executables, Visual Studio 2008 Standard Edition is required at the very 9least. In order to build all of the above, as well as generate release builds 10that make use of Profile Guided Optimisation (PG0), Visual Studio 2008 11Professional Edition is required at the very least. The official Python 12releases are built with this version of Visual Studio. 13 14For other Windows platforms and compilers, see PC/readme.txt. 15 16All you need to do is open the workspace "pcbuild.sln" in Visual Studio, 17select the desired combination of configuration and platform and eventually 18build the solution. Unless you are going to debug a problem in the core or 19you are going to create an optimized build you want to select "Release" as 20configuration. 21 22The PCbuild directory is compatible with all versions of Visual Studio from 23VS C++ Express Edition over the standard edition up to the professional 24edition. However the express edition does not support features like solution 25folders or profile guided optimization (PGO). The missing bits and pieces 26won't stop you from building Python. 27 28The solution is configured to build the projects in the correct order. "Build 29Solution" or F7 takes care of dependencies except for x64 builds. To make 30cross compiling x64 builds on a 32bit OS possible the x64 builds require a 3132bit version of Python. 32 33NOTE: 34 You probably don't want to build most of the other subprojects, unless 35 you're building an entire Python distribution from scratch, or 36 specifically making changes to the subsystems they implement, or are 37 running a Python core buildbot test slave; see SUBPROJECTS below) 38 39When using the Debug setting, the output files have a _d added to 40their name: python27_d.dll, python_d.exe, parser_d.pyd, and so on. Both 41the build and rt batch files accept a -d option for debug builds. 42 43The 32bit builds end up in the solution folder PCbuild while the x64 builds 44land in the amd64 subfolder. The PGI and PGO builds for profile guided 45optimization end up in their own folders, too. 46 47Legacy support 48-------------- 49 50You can find build directories for older versions of Visual Studio and 51Visual C++ in the PC directory. The legacy build directories are no longer 52actively maintained and may not work out of the box. 53 54PC/VC6/ 55 Visual C++ 6.0 56PC/VS7.1/ 57 Visual Studio 2003 (7.1) 58PC/VS8.0/ 59 Visual Studio 2005 (8.0) 60 61 62C RUNTIME 63--------- 64 65Visual Studio 2008 uses version 9 of the C runtime (MSVCRT9). The executables 66are linked to a CRT "side by side" assembly which must be present on the target 67machine. This is available under the VC/Redist folder of your visual studio 68distribution. On XP and later operating systems that support 69side-by-side assemblies it is not enough to have the msvcrt90.dll present, 70it has to be there as a whole assembly, that is, a folder with the .dll 71and a .manifest. Also, a check is made for the correct version. 72Therefore, one should distribute this assembly with the dlls, and keep 73it in the same directory. For compatibility with older systems, one should 74also set the PATH to this directory so that the dll can be found. 75For more info, see the Readme in the VC/Redist folder. 76 77SUBPROJECTS 78----------- 79These subprojects should build out of the box. Subprojects other than the 80main ones (pythoncore, python, pythonw) generally build a DLL (renamed to 81.pyd) from a specific module so that users don't have to load the code 82supporting that module unless they import the module. 83 84pythoncore 85 .dll and .lib 86python 87 .exe 88pythonw 89 pythonw.exe, a variant of python.exe that doesn't pop up a DOS box 90_socket 91 socketmodule.c 92_testcapi 93 tests of the Python C API, run via Lib/test/test_capi.py, and 94 implemented by module Modules/_testcapimodule.c 95pyexpat 96 Python wrapper for accelerated XML parsing, which incorporates stable 97 code from the Expat project: http://sourceforge.net/projects/expat/ 98select 99 selectmodule.c 100unicodedata 101 large tables of Unicode data 102winsound 103 play sounds (typically .wav files) under Windows 104 105Python-controlled subprojects that wrap external projects: 106_bsddb 107 Wraps Berkeley DB 4.7.25, which is currently built by _bsddb.vcproj. 108 project. 109_sqlite3 110 Wraps SQLite 3.8.11.0, which is currently built by sqlite3.vcproj. 111_tkinter 112 Wraps the Tk windowing system. Unlike _bsddb and _sqlite3, there's no 113 corresponding tcltk.vcproj-type project that builds Tcl/Tk from vcproj's 114 within our pcbuild.sln, which means this module expects to find a 115 pre-built Tcl/Tk in either ..\externals\tcltk for 32-bit or 116 ..\externals\tcltk64 for 64-bit (relative to this directory). See below 117 for instructions to build Tcl/Tk. 118bz2 119 Python wrapper for the libbz2 compression library. Homepage 120 http://sources.redhat.com/bzip2/ 121 Download the source from the python.org copy into the dist 122 directory: 123 124 svn export http://svn.python.org/projects/external/bzip2-1.0.6 125 126 ** NOTE: if you use the PCbuild\get_externals.bat approach for 127 obtaining external sources then you don't need to manually get the source 128 above via subversion. ** 129 130_ssl 131 Python wrapper for the secure sockets library. 132 133 Get the source code through 134 135 svn export http://svn.python.org/projects/external/openssl-1.0.2o 136 137 ** NOTE: if you use the PCbuild\get_externals.bat approach for 138 obtaining external sources then you don't need to manually get the source 139 above via subversion. ** 140 141 The NASM assembler is required to build OpenSSL. If you use the 142 PCbuild\get_externals.bat script to get external library sources, it also 143 downloads a version of NASM, which the ssl build script will add to PATH. 144 Otherwise, you can download the NASM installer from 145 http://www.nasm.us/ 146 and add NASM to your PATH. 147 148 You will also need ActivePerl from 149 http://www.activestate.com/activeperl/ 150 in order to create the necessary makefiles and .asm files for building 151 OpenSSL. 152 153 The build process makes sure that no patented algorithms are included. 154 For now RC5, MDC2 and IDEA are excluded from the build. You may have 155 to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process 156 complains about missing files or forbidden IDEA. Again the files provided 157 in the subversion repository are already fixed. 158 159 The MSVC project simply invokes PCBuild/build_ssl.py to perform 160 the build. This Python script locates and builds your OpenSSL 161 installation, then invokes a simple makefile to build the final .pyd. 162 163 build_ssl.py attempts to catch the most common errors (such as not 164 being able to find OpenSSL sources, or not being able to find a Perl 165 that works with OpenSSL) and give a reasonable error message. 166 If you have a problem that doesn't seem to be handled correctly 167 (eg, you know you have ActivePerl but we can't find it), please take 168 a peek at build_ssl.py and suggest patches. Note that build_ssl.py 169 should be able to be run directly from the command-line. 170 171 build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do 172 this by hand. 173 174The subprojects above wrap external projects Python doesn't control, and as 175such, a little more work is required in order to download the relevant source 176files for each project before they can be built. The easiest way to do this 177is to use the `build.bat` script in this directory to build Python, and pass 178the '-e' switch to tell it to use get_externals.bat to fetch external sources 179and build Tcl/Tk and Tix. To use get_externals.bat, you'll need to have 180Subversion installed and svn.exe on your PATH. The script will fetch external 181library sources from http://svn.python.org/external and place them in 182..\externals (relative to this directory). 183 184Building for Itanium 185-------------------- 186 187Official support for Itanium builds have been dropped from the build. Please 188contact us and provide patches if you are interested in Itanium builds. 189 190Building for AMD64 191------------------ 192 193The build process for AMD64 / x64 is very similar to standard builds. You just 194have to set x64 as platform. In addition, the HOST_PYTHON environment variable 195must point to a Python interpreter (at least 2.4), to support cross-compilation. 196 197Building Python Using the free MS Toolkit Compiler 198-------------------------------------------------- 199 200Microsoft has withdrawn the free MS Toolkit Compiler, so this can no longer 201be considered a supported option. Instead you can use the free VS C++ Express 202Edition. 203 204Profile Guided Optimization 205--------------------------- 206 207The solution has two configurations for PGO. The PGInstrument 208configuration must be build first. The PGInstrument binaries are 209linked against a profiling library and contain extra debug 210information. The PGUpdate configuration takes the profiling data and 211generates optimized binaries. 212 213The build_pgo.bat script automates the creation of optimized binaries. It 214creates the PGI files, runs the unit test suite or PyBench with the PGI 215python and finally creates the optimized files. 216 217http://msdn.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx 218 219Static library 220-------------- 221 222The solution has no configuration for static libraries. However it is easy 223it build a static library instead of a DLL. You simply have to set the 224"Configuration Type" to "Static Library (.lib)" and alter the preprocessor 225macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to 226change the "Runtime Library" from "Multi-threaded DLL (/MD)" to 227"Multi-threaded (/MT)". 228 229Visual Studio properties 230------------------------ 231 232The PCbuild solution makes heavy use of Visual Studio property files 233(*.vsprops). The properties can be viewed and altered in the Property 234Manager (View -> Other Windows -> Property Manager). 235 236 * debug (debug macro: _DEBUG) 237 * pginstrument (PGO) 238 * pgupdate (PGO) 239 +-- pginstrument 240 * pyd (python extension, release build) 241 +-- release 242 +-- pyproject 243 * pyd_d (python extension, debug build) 244 +-- debug 245 +-- pyproject 246 * pyproject (base settings for all projects, user macros like PyDllName) 247 * release (release macro: NDEBUG) 248 * x64 (AMD64 / x64 platform specific settings) 249 250The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64 251although the macros are set by the compiler, too. The GUI doesn't always know 252about the macros and confuse the user with false information. 253