/PCbuild/readme.txt

http://unladen-swallow.googlecode.com/ · Plain Text · 334 lines · 270 code · 64 blank · 0 comment · 0 complexity · 1308d51fcd20dbe047bea3ffee148bb1 MD5 · raw file

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