Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 1 | Building Python using VC++ 9.0 |
| 2 | ------------------------------ |
Christian Heimes | 57dddfb | 2008-01-02 18:30:52 +0000 | [diff] [blame] | 3 | |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 4 | This directory is used to build Python for Win32 and x64 platforms, e.g. |
| 5 | Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit |
| 6 | debug and release executables, Microsoft Visual C++ 2008 Express Edition is |
| 7 | required at the very least. In order to build 64-bit debug and release |
| 8 | executables, Visual Studio 2008 Standard Edition is required at the very |
| 9 | least. In order to build all of the above, as well as generate release builds |
| 10 | that make use of Profile Guided Optimisation (PG0), Visual Studio 2008 |
| 11 | Professional Edition is required at the very least. The official Python |
| 12 | releases are built with this version of Visual Studio. |
| 13 | |
| 14 | For other Windows platforms and compilers, see ../PC/readme.txt. |
Guido van Rossum | 15b239f | 1998-05-26 14:16:23 +0000 | [diff] [blame] | 15 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 16 | All you need to do is open the workspace "pcbuild.sln" in Visual Studio, |
| 17 | select the desired combination of configuration and platform and eventually |
| 18 | build the solution. Unless you are going to debug a problem in the core or |
| 19 | you are going to create an optimized build you want to select "Release" as |
| 20 | configuration. |
Guido van Rossum | 15b239f | 1998-05-26 14:16:23 +0000 | [diff] [blame] | 21 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 22 | The PCbuild directory is compatible with all versions of Visual Studio from |
| 23 | VS C++ Express Edition over the standard edition up to the professional |
Benjamin Peterson | 9bc9351 | 2008-09-22 22:10:59 +0000 | [diff] [blame] | 24 | edition. However the express edition does not support features like solution |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 25 | folders or profile guided optimization (PGO). The missing bits and pieces |
| 26 | won't stop you from building Python. |
Guido van Rossum | 15b239f | 1998-05-26 14:16:23 +0000 | [diff] [blame] | 27 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 28 | The solution is configured to build the projects in the correct order. "Build |
Christian Heimes | a822314 | 2008-02-09 20:58:00 +0000 | [diff] [blame] | 29 | Solution" or F7 takes care of dependencies except for x64 builds. To make |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 30 | cross compiling x64 builds on a 32bit OS possible the x64 builds require a |
| 31 | 32bit version of Python. |
Guido van Rossum | 15b239f | 1998-05-26 14:16:23 +0000 | [diff] [blame] | 32 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 33 | NOTE: |
| 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) |
Guido van Rossum | 15b239f | 1998-05-26 14:16:23 +0000 | [diff] [blame] | 38 | |
| 39 | When using the Debug setting, the output files have a _d added to |
Georg Brandl | fa2c61a | 2011-02-20 10:41:31 +0000 | [diff] [blame] | 40 | their name: python33_d.dll, python_d.exe, parser_d.pyd, and so on. Both |
Christian Heimes | a822314 | 2008-02-09 20:58:00 +0000 | [diff] [blame] | 41 | the build and rt batch files accept a -d option for debug builds. |
Guido van Rossum | e79cf32 | 1998-07-07 22:35:03 +0000 | [diff] [blame] | 42 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 43 | The 32bit builds end up in the solution folder PCbuild while the x64 builds |
| 44 | land in the amd64 subfolder. The PGI and PGO builds for profile guided |
| 45 | optimization end up in their own folders, too. |
| 46 | |
Christian Heimes | 57dddfb | 2008-01-02 18:30:52 +0000 | [diff] [blame] | 47 | Legacy support |
| 48 | -------------- |
| 49 | |
| 50 | You can find build directories for older versions of Visual Studio and |
| 51 | Visual C++ in the PC directory. The legacy build directories are no longer |
| 52 | actively maintained and may not work out of the box. |
| 53 | |
| 54 | PC/VC6/ |
| 55 | Visual C++ 6.0 |
| 56 | PC/VS7.1/ |
| 57 | Visual Studio 2003 (7.1) |
Hirokazu Yamamoto | 0b0ebb4 | 2010-10-01 10:40:49 +0000 | [diff] [blame] | 58 | PC/VS8.0/ |
Christian Heimes | 57dddfb | 2008-01-02 18:30:52 +0000 | [diff] [blame] | 59 | Visual Studio 2005 (8.0) |
| 60 | |
| 61 | |
| 62 | C RUNTIME |
| 63 | --------- |
| 64 | |
| 65 | Visual Studio 2008 uses version 9 of the C runtime (MSVCRT9). The executables |
| 66 | are linked to a CRT "side by side" assembly which must be present on the target |
| 67 | machine. This is avalible under the VC/Redist folder of your visual studio |
| 68 | distribution. On XP and later operating systems that support |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 69 | side-by-side assemblies it is not enough to have the msvcrt90.dll present, |
Christian Heimes | 57dddfb | 2008-01-02 18:30:52 +0000 | [diff] [blame] | 70 | it has to be there as a whole assembly, that is, a folder with the .dll |
| 71 | and a .manifest. Also, a check is made for the correct version. |
| 72 | Therefore, one should distribute this assembly with the dlls, and keep |
| 73 | it in the same directory. For compatibility with older systems, one should |
| 74 | also set the PATH to this directory so that the dll can be found. |
| 75 | For more info, see the Readme in the VC/Redist folder. |
| 76 | |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 77 | SUBPROJECTS |
| 78 | ----------- |
Tim Peters | 610a827 | 2000-07-01 02:51:23 +0000 | [diff] [blame] | 79 | These subprojects should build out of the box. Subprojects other than the |
Tim Peters | befc97c | 2001-01-18 19:01:39 +0000 | [diff] [blame] | 80 | main ones (pythoncore, python, pythonw) generally build a DLL (renamed to |
Tim Peters | 610a827 | 2000-07-01 02:51:23 +0000 | [diff] [blame] | 81 | .pyd) from a specific module so that users don't have to load the code |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 82 | supporting that module unless they import the module. |
Guido van Rossum | e79cf32 | 1998-07-07 22:35:03 +0000 | [diff] [blame] | 83 | |
Tim Peters | 97c9640 | 2001-01-17 23:23:13 +0000 | [diff] [blame] | 84 | pythoncore |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 85 | .dll and .lib |
| 86 | python |
| 87 | .exe |
| 88 | pythonw |
| 89 | pythonw.exe, a variant of python.exe that doesn't pop up a DOS box |
| 90 | _socket |
| 91 | socketmodule.c |
Tim Peters | d66595f | 2001-02-04 03:09:53 +0000 | [diff] [blame] | 92 | _testcapi |
Tim Peters | b16c56f | 2001-02-02 21:24:51 +0000 | [diff] [blame] | 93 | tests of the Python C API, run via Lib/test/test_capi.py, and |
Tim Peters | d66595f | 2001-02-04 03:09:53 +0000 | [diff] [blame] | 94 | implemented by module Modules/_testcapimodule.c |
Tim Peters | b012a15 | 2002-02-13 23:56:46 +0000 | [diff] [blame] | 95 | pyexpat |
| 96 | Python wrapper for accelerated XML parsing, which incorporates stable |
| 97 | code from the Expat project: http://sourceforge.net/projects/expat/ |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 98 | select |
| 99 | selectmodule.c |
Tim Peters | 19f52c2 | 2001-01-24 10:07:22 +0000 | [diff] [blame] | 100 | unicodedata |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 101 | large tables of Unicode data |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 102 | winsound |
| 103 | play sounds (typically .wav files) under Windows |
| 104 | |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 105 | Python-controlled subprojects that wrap external projects: |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 106 | _sqlite3 |
Martin v. Löwis | 0e74cac | 2010-12-17 21:04:09 +0000 | [diff] [blame] | 107 | Wraps SQLite 3.7.4, which is currently built by sqlite3.vcproj (see below). |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 108 | _tkinter |
Georg Brandl | 1158a33 | 2009-06-04 09:30:30 +0000 | [diff] [blame] | 109 | Wraps the Tk windowing system. Unlike _sqlite3, there's no |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 110 | corresponding tcltk.vcproj-type project that builds Tcl/Tk from vcproj's |
| 111 | within our pcbuild.sln, which means this module expects to find a |
| 112 | pre-built Tcl/Tk in either ..\..\tcltk for 32-bit or ..\..\tcltk64 for |
| 113 | 64-bit (relative to this directory). See below for instructions to build |
| 114 | Tcl/Tk. |
Antoine Pitrou | 37dc5f8 | 2011-04-03 17:05:46 +0200 | [diff] [blame] | 115 | _bz2 |
| 116 | Python wrapper for the libbzip2 compression library. Homepage |
| 117 | http://www.bzip.org/ |
Martin v. Löwis | f6f7925 | 2006-03-13 13:48:05 +0000 | [diff] [blame] | 118 | Download the source from the python.org copy into the dist |
| 119 | directory: |
| 120 | |
Martin v. Löwis | 70ce8aa | 2008-06-13 17:28:35 +0000 | [diff] [blame] | 121 | svn export http://svn.python.org/projects/external/bzip2-1.0.5 |
Tim Peters | 077736b | 2002-11-14 23:24:40 +0000 | [diff] [blame] | 122 | |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 123 | ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for |
| 124 | obtaining external sources then you don't need to manually get the source |
| 125 | above via subversion. ** |
| 126 | |
Thomas Heller | 46a007e | 2003-08-20 18:27:36 +0000 | [diff] [blame] | 127 | A custom pre-link step in the bz2 project settings should manage to |
Martin v. Löwis | 70ce8aa | 2008-06-13 17:28:35 +0000 | [diff] [blame] | 128 | build bzip2-1.0.5\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is |
Thomas Heller | 46a007e | 2003-08-20 18:27:36 +0000 | [diff] [blame] | 129 | linked in PCbuild\. |
| 130 | However, the bz2 project is not smart enough to remove anything under |
Martin v. Löwis | 70ce8aa | 2008-06-13 17:28:35 +0000 | [diff] [blame] | 131 | bzip2-1.0.5\ when you do a clean, so if you want to rebuild bzip2.lib |
| 132 | you need to clean up bzip2-1.0.5\ by hand. |
Tim Peters | 077736b | 2002-11-14 23:24:40 +0000 | [diff] [blame] | 133 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 134 | All of this managed to build libbz2.lib in |
Martin v. Löwis | 70ce8aa | 2008-06-13 17:28:35 +0000 | [diff] [blame] | 135 | bzip2-1.0.5\$platform-$configuration\, which the Python project links in. |
Tim Peters | b0ead4e | 2002-11-09 04:48:58 +0000 | [diff] [blame] | 136 | |
Mark Hammond | f229f9f | 2002-12-03 05:47:26 +0000 | [diff] [blame] | 137 | _ssl |
Tim Peters | e8bcb25 | 2002-12-04 02:39:52 +0000 | [diff] [blame] | 138 | Python wrapper for the secure sockets library. |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 139 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 140 | Get the source code through |
Mark Hammond | f229f9f | 2002-12-03 05:47:26 +0000 | [diff] [blame] | 141 | |
Martin v. Löwis | e38de85 | 2010-07-30 17:30:51 +0000 | [diff] [blame] | 142 | svn export http://svn.python.org/projects/external/openssl-1.0.0a |
Tim Peters | e8bcb25 | 2002-12-04 02:39:52 +0000 | [diff] [blame] | 143 | |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 144 | ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for |
| 145 | obtaining external sources then you don't need to manually get the source |
| 146 | above via subversion. ** |
| 147 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 148 | Alternatively, get the latest version from http://www.openssl.org. |
Mark Hammond | f229f9f | 2002-12-03 05:47:26 +0000 | [diff] [blame] | 149 | You can (theoretically) use any version of OpenSSL you like - the |
| 150 | build process will automatically select the latest version. |
| 151 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 152 | You must install the NASM assembler from |
Benjamin Peterson | e5384b0 | 2008-10-04 22:00:42 +0000 | [diff] [blame] | 153 | http://nasm.sf.net |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 154 | for x86 builds. Put nasmw.exe anywhere in your PATH. |
Georg Brandl | 0abcbd7 | 2010-08-02 19:43:05 +0000 | [diff] [blame] | 155 | Note: recent releases of nasm only have nasm.exe. Just rename it to |
| 156 | nasmw.exe. |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 157 | |
| 158 | You can also install ActivePerl from |
Hirokazu Yamamoto | 7c3d709 | 2010-10-28 17:57:25 +0000 | [diff] [blame] | 159 | http://www.activestate.com/activeperl/ |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 160 | if you like to use the official sources instead of the files from |
| 161 | python's subversion repository. The svn version contains pre-build |
| 162 | makefiles and assembly files. |
| 163 | |
| 164 | The build process makes sure that no patented algorithms are included. |
| 165 | For now RC5, MDC2 and IDEA are excluded from the build. You may have |
| 166 | to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process |
| 167 | complains about missing files or forbidden IDEA. Again the files provided |
| 168 | in the subversion repository are already fixed. |
Mark Hammond | f229f9f | 2002-12-03 05:47:26 +0000 | [diff] [blame] | 169 | |
| 170 | The MSVC project simply invokes PCBuild/build_ssl.py to perform |
Tim Peters | e8bcb25 | 2002-12-04 02:39:52 +0000 | [diff] [blame] | 171 | the build. This Python script locates and builds your OpenSSL |
Mark Hammond | f229f9f | 2002-12-03 05:47:26 +0000 | [diff] [blame] | 172 | installation, then invokes a simple makefile to build the final .pyd. |
| 173 | |
| 174 | build_ssl.py attempts to catch the most common errors (such as not |
| 175 | being able to find OpenSSL sources, or not being able to find a Perl |
| 176 | that works with OpenSSL) and give a reasonable error message. |
| 177 | If you have a problem that doesn't seem to be handled correctly |
| 178 | (eg, you know you have ActivePerl but we can't find it), please take |
| 179 | a peek at build_ssl.py and suggest patches. Note that build_ssl.py |
| 180 | should be able to be run directly from the command-line. |
| 181 | |
Tim Peters | e8bcb25 | 2002-12-04 02:39:52 +0000 | [diff] [blame] | 182 | build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do |
| 183 | this by hand. |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 184 | |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 185 | The subprojects above wrap external projects Python doesn't control, and as |
| 186 | such, a little more work is required in order to download the relevant source |
| 187 | files for each project before they can be built. The buildbots do this each |
| 188 | time they're built, so the easiest approach is to run either external.bat or |
| 189 | external-amd64.bat in the ..\Tools\buildbot directory from ..\, i.e.: |
| 190 | |
| 191 | C:\..\svn.python.org\projects\python\trunk\PCbuild>cd .. |
| 192 | C:\..\svn.python.org\projects\python\trunk>Tools\buildbot\external.bat |
| 193 | |
| 194 | This extracts all the external subprojects from http://svn.python.org/external |
| 195 | via Subversion (so you'll need an svn.exe on your PATH) and places them in |
| 196 | ..\.. (relative to this directory). The external(-amd64).bat scripts will |
| 197 | also build a debug build of Tcl/Tk; there aren't any equivalent batch files |
| 198 | for building release versions of Tcl/Tk lying around in the Tools\buildbot |
| 199 | directory. If you need to build a release version of Tcl/Tk it isn't hard |
| 200 | though, take a look at the relevant external(-amd64).bat file and find the |
| 201 | two nmake lines, then call each one without the 'DEBUG=1' parameter, i.e.: |
| 202 | |
| 203 | The external-amd64.bat file contains this for tcl: |
| 204 | nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install |
| 205 | |
| 206 | So for a release build, you'd call it as: |
| 207 | nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install |
| 208 | |
| 209 | XXX Should we compile with OPTS=threads? |
| 210 | XXX Our installer copies a lot of stuff out of the Tcl/Tk install |
| 211 | XXX directory. Is all of that really needed for Python use of Tcl/Tk? |
| 212 | |
| 213 | This will be cleaned up in the future; ideally Tcl/Tk will be brought into our |
| 214 | pcbuild.sln as custom .vcproj files, just as we've recently done with the |
Georg Brandl | 1158a33 | 2009-06-04 09:30:30 +0000 | [diff] [blame] | 215 | sqlite3.vcproj file, which will remove the need for Tcl/Tk to be built |
| 216 | separately via a batch file. |
Trent Nelson | 5203727 | 2008-04-02 15:06:49 +0000 | [diff] [blame] | 217 | |
| 218 | XXX trent.nelson 02-Apr-08: |
| 219 | Having the external subprojects in ..\.. relative to this directory is a |
| 220 | bit of a nuisance when you're working on py3k and trunk in parallel and |
| 221 | your directory layout mimics that of Python's subversion layout, e.g.: |
| 222 | |
| 223 | C:\..\svn.python.org\projects\python\trunk |
| 224 | C:\..\svn.python.org\projects\python\branches\py3k |
| 225 | C:\..\svn.python.org\projects\python\branches\release25-maint |
| 226 | |
| 227 | I'd like to change things so that external subprojects are fetched from |
| 228 | ..\external instead of ..\.., then provide some helper scripts or batch |
| 229 | files that would set up a new ..\external directory with svn checkouts of |
| 230 | the relevant branches in http://svn.python.org/projects/external/, or |
| 231 | alternatively, use junctions to link ..\external with a pre-existing |
| 232 | externals directory being used by another branch. i.e. if I'm usually |
| 233 | working on trunk (and have previously created trunk\external via the |
| 234 | provided batch file), and want to do some work on py3k, I'd set up a |
| 235 | junction as follows (using the directory structure above as an example): |
| 236 | |
| 237 | C:\..\python\trunk\external <- already exists and has built versions |
| 238 | of the external subprojects |
| 239 | |
| 240 | C:\..\python\branches\py3k>linkd.exe external ..\..\trunk\external |
| 241 | Link created at: external |
| 242 | |
| 243 | Only a slight tweak would be needed to the buildbots such that bots |
| 244 | building trunk and py3k could make use of the same facility. (2.5.x |
| 245 | builds need to be kept separate as they're using Visual Studio 7.1.) |
| 246 | /XXX trent.nelson 02-Apr-08 |
| 247 | |
Martin v. Löwis | 13e50fe | 2004-07-20 14:37:48 +0000 | [diff] [blame] | 248 | Building for Itanium |
| 249 | -------------------- |
| 250 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 251 | NOTE: |
| 252 | Official support for Itanium builds have been dropped from the build. Please |
Christian Heimes | a822314 | 2008-02-09 20:58:00 +0000 | [diff] [blame] | 253 | contact us and provide patches if you are interested in Itanium builds. |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 254 | |
Tim Peters | e82b00f | 2004-08-30 21:14:51 +0000 | [diff] [blame] | 255 | The project files support a ReleaseItanium configuration which creates |
Martin v. Löwis | 13e50fe | 2004-07-20 14:37:48 +0000 | [diff] [blame] | 256 | Win64/Itanium binaries. For this to work, you need to install the Platform |
| 257 | SDK, in particular the 64-bit support. This includes an Itanium compiler |
| 258 | (future releases of the SDK likely include an AMD64 compiler as well). |
| 259 | In addition, you need the Visual Studio plugin for external C compilers, |
| 260 | from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to |
Tim Peters | e82b00f | 2004-08-30 21:14:51 +0000 | [diff] [blame] | 261 | locate the proper target compiler, and convert compiler options |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 262 | accordingly. The project files require atleast version 0.9. |
Martin v. Löwis | 13e50fe | 2004-07-20 14:37:48 +0000 | [diff] [blame] | 263 | |
Martin v. Löwis | 856bf9a | 2006-02-14 20:42:55 +0000 | [diff] [blame] | 264 | Building for AMD64 |
| 265 | ------------------ |
| 266 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 267 | The build process for AMD64 / x64 is very similar to standard builds. You just |
Martin v. Löwis | 1561bab | 2008-02-29 19:39:25 +0000 | [diff] [blame] | 268 | have to set x64 as platform. In addition, the HOST_PYTHON environment variable |
| 269 | must point to a Python interpreter (at least 2.4), to support cross-compilation. |
Martin v. Löwis | 856bf9a | 2006-02-14 20:42:55 +0000 | [diff] [blame] | 270 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 271 | Building Python Using the free MS Toolkit Compiler |
| 272 | -------------------------------------------------- |
| 273 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 274 | Microsoft has withdrawn the free MS Toolkit Compiler, so this can no longer |
| 275 | be considered a supported option. Instead you can use the free VS C++ Express |
| 276 | Edition. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 277 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 278 | Profile Guided Optimization |
| 279 | --------------------------- |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 280 | |
Christian Heimes | 25bb783 | 2008-01-11 16:17:00 +0000 | [diff] [blame] | 281 | The solution has two configurations for PGO. The PGInstrument |
| 282 | configuration must be build first. The PGInstrument binaries are |
| 283 | lniked against a profiling library and contain extra debug |
| 284 | information. The PGUpdate configuration takes the profiling data and |
| 285 | generates optimized binaries. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 286 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 287 | The build_pgo.bat script automates the creation of optimized binaries. It |
| 288 | creates the PGI files, runs the unit test suite or PyBench with the PGI |
| 289 | python and finally creates the optimized files. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 290 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 291 | http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 292 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 293 | Static library |
| 294 | -------------- |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 295 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 296 | The solution has no configuration for static libraries. However it is easy |
| 297 | it build a static library instead of a DLL. You simply have to set the |
| 298 | "Configuration Type" to "Static Library (.lib)" and alter the preprocessor |
| 299 | macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to |
| 300 | change the "Runtime Library" from "Multi-threaded DLL (/MD)" to |
| 301 | "Multi-threaded (/MT)". |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 302 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 303 | Visual Studio properties |
| 304 | ------------------------ |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 305 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 306 | The PCbuild solution makes heavy use of Visual Studio property files |
| 307 | (*.vsprops). The properties can be viewed and altered in the Property |
| 308 | Manager (View -> Other Windows -> Property Manager). |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 309 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 310 | * debug (debug macro: _DEBUG) |
| 311 | * pginstrument (PGO) |
| 312 | * pgupdate (PGO) |
| 313 | +-- pginstrument |
| 314 | * pyd (python extension, release build) |
| 315 | +-- release |
| 316 | +-- pyproject |
| 317 | * pyd_d (python extension, debug build) |
| 318 | +-- debug |
| 319 | +-- pyproject |
| 320 | * pyproject (base settings for all projects, user macros like PyDllName) |
| 321 | * release (release macro: NDEBUG) |
| 322 | * x64 (AMD64 / x64 platform specific settings) |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 323 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 324 | The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64 |
| 325 | although the macros are set by the compiler, too. The GUI doesn't always know |
| 326 | about the macros and confuse the user with false information. |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 327 | |
Tim Peters | f9a4a6e | 2000-07-01 20:38:27 +0000 | [diff] [blame] | 328 | YOUR OWN EXTENSION DLLs |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 329 | ----------------------- |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 330 | |
Tim Peters | 4b5fb07 | 2000-07-01 00:03:43 +0000 | [diff] [blame] | 331 | If you want to create your own extension module DLL, there's an example |
| 332 | with easy-to-follow instructions in ../PC/example/; read the file |
| 333 | readme.txt there first. |