You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

342 lines
14 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. Quick Start Guide
  2. -----------------
  3. 1. Install Microsoft Visual Studio 2015, any edition.
  4. 2. Install Subversion, and make sure 'svn.exe' is on your PATH.
  5. 3. Run "build.bat -e" to build Python in 32-bit Release configuration.
  6. 4. (Optional, but recommended) Run the test suite with "rt.bat -q".
  7. Building Python using Microsoft Visual C++
  8. ------------------------------------------
  9. This directory is used to build CPython for Microsoft Windows NT version
  10. 6.0 or higher (Windows Vista, Windows Server 2008, or later) on 32 and 64
  11. bit platforms. Using this directory requires an installation of
  12. Microsoft Visual C++ 2015 (MSVC 14.0) of any edition. The specific
  13. requirements are as follows:
  14. Visual Studio Express 2015 for Desktop
  15. Visual Studio Professional 2015
  16. Either edition is sufficient for building all configurations except
  17. for Profile Guided Optimization.
  18. The Python build solution pcbuild.sln makes use of Solution Folders,
  19. which this edition does not support. Any time pcbuild.sln is opened
  20. or reloaded by Visual Studio, a warning about Solution Folders will
  21. be displayed, which can be safely dismissed with no impact on your
  22. ability to build Python.
  23. Required for building 64-bit Debug and Release configuration builds
  24. Visual Studio Premium 2015
  25. Required for building Release configuration builds that make use of
  26. Profile Guided Optimization (PGO), on either platform.
  27. All you need to do to build is open the solution "pcbuild.sln" in Visual
  28. Studio, select the desired combination of configuration and platform,
  29. then build with "Build Solution". You can also build from the command
  30. line using the "build.bat" script in this directory; see below for
  31. details. The solution is configured to build the projects in the correct
  32. order.
  33. The solution currently supports two platforms. The Win32 platform is
  34. used to build standard x86-compatible 32-bit binaries, output into the
  35. win32 sub-directory. The x64 platform is used for building 64-bit AMD64
  36. (aka x86_64 or EM64T) binaries, output into the amd64 sub-directory.
  37. The Itanium (IA-64) platform is no longer supported. See the "Building
  38. for AMD64" section below for more information about 64-bit builds.
  39. Four configuration options are supported by the solution:
  40. Debug
  41. Used to build Python with extra debugging capabilities, equivalent
  42. to using ./configure --with-pydebug on UNIX. All binaries built
  43. using this configuration have "_d" added to their name:
  44. python35_d.dll, python_d.exe, parser_d.pyd, and so on. Both the
  45. build and rt (run test) batch files in this directory accept a -d
  46. option for debug builds. If you are building Python to help with
  47. development of CPython, you will most likely use this configuration.
  48. PGInstrument, PGUpdate
  49. Used to build Python in Release configuration using PGO, which
  50. requires Premium Edition of Visual Studio. See the "Profile
  51. Guided Optimization" section below for more information. Build
  52. output from each of these configurations lands in its own
  53. sub-directory of this directory. The official Python releases may
  54. be built using these configurations.
  55. Release
  56. Used to build Python as it is meant to be used in production
  57. settings, though without PGO.
  58. Building Python using the build.bat script
  59. ----------------------------------------------
  60. In this directory you can find build.bat, a script designed to make
  61. building Python on Windows simpler. This script will use the env.bat
  62. script to detect one of Visual Studio 2015, 2013, 2012, or 2010, any of
  63. which may be used to build Python, though only Visual Studio 2015 is
  64. officially supported.
  65. By default, build.bat will build Python in Release configuration for
  66. the 32-bit Win32 platform. It accepts several arguments to change
  67. this behavior:
  68. -c <configuration> Set the configuration (see above)
  69. -d Shortcut for "-c Debug"
  70. -p <platform> Set the platform to build for ("Win32" or "x64")
  71. -r Rebuild instead of just building
  72. -t <target> Set the target (Build, Rebuild, Clean or CleanAll)
  73. -e Use get_externals.bat to fetch external sources
  74. -M Don't build in parallel
  75. -v Increased output messages
  76. Up to 9 MSBuild switches can also be passed, though they must be passed
  77. after specifying any of the above switches. For example, use:
  78. build.bat -e -d /fl
  79. to do a debug build with externals fetched as needed and write detailed
  80. build logs to a file. If the MSBuild switch requires an equal sign
  81. ("="), the entire switch must be quoted:
  82. build.bat -e -d "/p:ExternalsDir=P:\cpython-externals"
  83. There may also be other situations where quotes are necessary.
  84. C Runtime
  85. ---------
  86. Visual Studio 2015 uses version 14 of the C runtime (MSVCRT14). The
  87. executables no longer use the "Side by Side" assemblies used in previous
  88. versions of the compiler. This simplifies distribution of applications.
  89. The run time libraries are available under the VC/Redist folder of your
  90. Visual Studio distribution. For more info, see the Readme in the
  91. VC/Redist folder.
  92. Sub-Projects
  93. ------------
  94. The CPython project is split up into several smaller sub-projects which
  95. are managed by the pcbuild.sln solution file. Each sub-project is
  96. represented by a .vcxproj and a .vcxproj.filters file starting with the
  97. name of the sub-project. These sub-projects fall into a few general
  98. categories:
  99. The following sub-projects represent the bare minimum required to build
  100. a functioning CPython interpreter. If nothing else builds but these,
  101. you'll have a very limited but usable python.exe:
  102. pythoncore
  103. .dll and .lib
  104. python
  105. .exe
  106. make_buildinfo, make_versioninfo
  107. helpers to provide necessary information to the build process
  108. These sub-projects provide extra executables that are useful for running
  109. CPython in different ways:
  110. pythonw
  111. pythonw.exe, a variant of python.exe that doesn't open a Command
  112. Prompt window
  113. pylauncher
  114. py.exe, the Python Launcher for Windows, see
  115. http://docs.python.org/3/using/windows.html#launcher
  116. pywlauncher
  117. pyw.exe, a variant of py.exe that doesn't open a Command Prompt
  118. window
  119. _testembed
  120. _testembed.exe, a small program that embeds Python for testing
  121. purposes, used by test_capi.py
  122. These are miscellaneous sub-projects that don't really fit the other
  123. categories:
  124. _freeze_importlib
  125. _freeze_importlib.exe, used to regenerate Python\importlib.h after
  126. changes have been made to Lib\importlib\_bootstrap.py
  127. bdist_wininst
  128. ..\Lib\distutils\command\wininst-14.0[-amd64].exe, the base
  129. executable used by the distutils bdist_wininst command
  130. python3dll
  131. python3.dll, the PEP 384 Stable ABI dll
  132. xxlimited
  133. builds an example module that makes use of the PEP 384 Stable ABI,
  134. see Modules\xxlimited.c
  135. The following sub-projects are for individual modules of the standard
  136. library which are implemented in C; each one builds a DLL (renamed to
  137. .pyd) of the same name as the project:
  138. _ctypes
  139. _ctypes_test
  140. _decimal
  141. _elementtree
  142. _hashlib
  143. _msi
  144. _multiprocessing
  145. _overlapped
  146. _socket
  147. _testcapi
  148. _testbuffer
  149. _testimportmultiple
  150. pyexpat
  151. select
  152. unicodedata
  153. winsound
  154. The following Python-controlled sub-projects wrap external projects.
  155. Note that these external libraries are not necessary for a working
  156. interpreter, but they do implement several major features. See the
  157. "Getting External Sources" section below for additional information
  158. about getting the source for building these libraries. The sub-projects
  159. are:
  160. _bz2
  161. Python wrapper for version 1.0.6 of the libbzip2 compression library
  162. Homepage:
  163. http://www.bzip.org/
  164. _lzma
  165. Python wrapper for the liblzma compression library, using pre-built
  166. binaries of XZ Utils version 5.0.5
  167. Homepage:
  168. http://tukaani.org/xz/
  169. _ssl
  170. Python wrapper for version 1.0.2d of the OpenSSL secure sockets
  171. library, which is built by ssl.vcxproj
  172. Homepage:
  173. http://www.openssl.org/
  174. Building OpenSSL requires nasm.exe (the Netwide Assembler), version
  175. 2.10 or newer from
  176. http://www.nasm.us/
  177. to be somewhere on your PATH. More recent versions of OpenSSL may
  178. need a later version of NASM. If OpenSSL's self tests don't pass,
  179. you should first try to update NASM and do a full rebuild of
  180. OpenSSL. If you use the PCbuild\get_externals.bat method
  181. for getting sources, it also downloads a version of NASM which the
  182. libeay/ssleay sub-projects use.
  183. The libeay/ssleay sub-projects expect your OpenSSL sources to have
  184. already been configured and be ready to build. If you get your sources
  185. from svn.python.org as suggested in the "Getting External Sources"
  186. section below, the OpenSSL source will already be ready to go. If
  187. you want to build a different version, you will need to run
  188. PCbuild\prepare_ssl.py path\to\openssl-source-dir
  189. That script will prepare your OpenSSL sources in the same way that
  190. those available on svn.python.org have been prepared. Note that
  191. Perl must be installed and available on your PATH to configure
  192. OpenSSL. ActivePerl is recommended and is available from
  193. http://www.activestate.com/activeperl/
  194. The libeay and ssleay sub-projects will build the modules of OpenSSL
  195. required by _ssl and _hashlib and may need to be manually updated when
  196. upgrading to a newer version of OpenSSL or when adding new
  197. functionality to _ssl or _hashlib. They will not clean up their output
  198. with the normal Clean target; CleanAll should be used instead.
  199. _sqlite3
  200. Wraps SQLite 3.8.11.0, which is itself built by sqlite3.vcxproj
  201. Homepage:
  202. http://www.sqlite.org/
  203. _tkinter
  204. Wraps version 8.6.1 of the Tk windowing system.
  205. Homepage:
  206. http://www.tcl.tk/
  207. Tkinter's dependencies are built by the tcl.vcxproj and tk.vcxproj
  208. projects. The tix.vcxproj project also builds the Tix extended
  209. widget set for use with Tkinter.
  210. Those three projects install their respective components in a
  211. directory alongside the source directories called "tcltk" on
  212. Win32 and "tcltk64" on x64. They also copy the Tcl and Tk DLLs
  213. into the current output directory, which should ensure that Tkinter
  214. is able to load Tcl/Tk without having to change your PATH.
  215. The tcl, tk, and tix sub-projects do not clean their builds with
  216. the normal Clean target; if you need to rebuild, you should use the
  217. CleanAll target or manually delete their builds.
  218. Getting External Sources
  219. ------------------------
  220. The last category of sub-projects listed above wrap external projects
  221. Python doesn't control, and as such a little more work is required in
  222. order to download the relevant source files for each project before they
  223. can be built. However, a simple script is provided to make this as
  224. painless as possible, called "get_externals.bat" and located in this
  225. directory. This script extracts all the external sub-projects from
  226. http://svn.python.org/projects/external
  227. via Subversion (so you'll need svn.exe on your PATH) and places them
  228. in ..\externals (relative to this directory).
  229. It is also possible to download sources from each project's homepage,
  230. though you may have to change folder names or pass the names to MSBuild
  231. as the values of certain properties in order for the build solution to
  232. find them. This is an advanced topic and not necessarily fully
  233. supported.
  234. Building for AMD64
  235. ------------------
  236. The build process for AMD64 / x64 is very similar to standard builds,
  237. you just have to set x64 as platform. In addition, the HOST_PYTHON
  238. environment variable must point to a Python interpreter (at least 2.4),
  239. to support cross-compilation from Win32.
  240. Profile Guided Optimization
  241. ---------------------------
  242. The solution has two configurations for PGO. The PGInstrument
  243. configuration must be built first. The PGInstrument binaries are linked
  244. against a profiling library and contain extra debug information. The
  245. PGUpdate configuration takes the profiling data and generates optimized
  246. binaries.
  247. The build_pgo.bat script automates the creation of optimized binaries.
  248. It creates the PGI files, runs the unit test suite or PyBench with the
  249. PGI python, and finally creates the optimized files.
  250. See
  251. http://msdn.microsoft.com/en-us/library/e7k32f4k(VS.100).aspx
  252. for more on this topic.
  253. Static library
  254. --------------
  255. The solution has no configuration for static libraries. However it is
  256. easy to build a static library instead of a DLL. You simply have to set
  257. the "Configuration Type" to "Static Library (.lib)" and alter the
  258. preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may
  259. also have to change the "Runtime Library" from "Multi-threaded DLL
  260. (/MD)" to "Multi-threaded (/MT)".
  261. Visual Studio properties
  262. ------------------------
  263. The PCbuild solution makes use of Visual Studio property files (*.props)
  264. to simplify each project. The properties can be viewed in the Property
  265. Manager (View -> Other Windows -> Property Manager) but should be
  266. carefully modified by hand.
  267. The property files used are:
  268. * python (versions, directories and build names)
  269. * pyproject (base settings for all projects)
  270. * openssl (used by libeay and ssleay projects)
  271. * tcltk (used by _tkinter, tcl, tk and tix projects)
  272. The pyproject property file defines all of the build settings for each
  273. project, with some projects overriding certain specific values. The GUI
  274. doesn't always reflect the correct settings and may confuse the user
  275. with false information, especially for settings that automatically adapt
  276. for diffirent configurations.
  277. Your Own Extension DLLs
  278. -----------------------
  279. If you want to create your own extension module DLL (.pyd), there's an
  280. example with easy-to-follow instructions in ..\PC\example\; read the
  281. file readme.txt there first.