~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to PCbuild/readme.txt

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Building Python using Microsoft Visual C++
 
2
------------------------------------------
 
3
 
 
4
This directory is used to build CPython for Microsoft Windows NT version
 
5
5.1 or higher (Windows XP, Windows Server 2003, or later) on 32 and 64
 
6
bit platforms.  Using this directory requires an installation of
 
7
Microsoft Visual C++ 2010 (MSVC 10.0) of any edition.  The specific
 
8
requirements are as follows:
 
9
Visual C++ 2010 Express Edition
 
10
    Required for building 32-bit Debug and Release configuration builds.
 
11
    This edition does not support "solution folders", which pcbuild.sln
 
12
    uses; this will not prevent building.
 
13
Visual Studio 2010 Standard Edition
 
14
    Required for building 64-bit Debug and Release configuration builds
 
15
Visual Studio 2010 Professional Edition
 
16
    Required for building Release configuration builds that make use of
 
17
    Profile Guided Optimization (PGO), on either platform.  The official
 
18
    Python releases are built with Professional Edition using PGO.
 
19
 
 
20
All you need to do to build is open the solution "pcbuild.sln" in Visual
 
21
Studio, select the desired combination of configuration and platform,
 
22
then build with "Build Solution" or the F7 keyboard shortcut.  You can
 
23
also build from the command line using the "build.bat" script in this
 
24
directory.  The solution is configured to build the projects in the
 
25
correct order.
 
26
 
 
27
The solution currently supports two platforms.  The Win32 platform is
 
28
used to build standard x86-compatible 32-bit binaries, output into this
 
29
directory.  The x64 platform is used for building 64-bit AMD64 (aka
 
30
x86_64 or EM64T) binaries, output into the amd64 sub-directory which
 
31
will be created if it doesn't already exist.  The Itanium (IA-64)
 
32
platform is no longer supported.  See the "Building for AMD64" section
 
33
below for more information about 64-bit builds.
 
34
 
 
35
Four configuration options are supported by the solution:
 
36
Debug
 
37
    Used to build Python with extra debugging capabilities, equivalent
 
38
    to using ./configure --with-pydebug on UNIX.  All binaries built
 
39
    using this configuration have "_d" added to their name:
 
40
    python34_d.dll, python_d.exe, parser_d.pyd, and so on.  Both the
 
41
    build and rt (run test) batch files in this directory accept a -d
 
42
    option for debug builds.  If you are building Python to help with
 
43
    development of CPython, you will most likely use this configuration.
 
44
PGInstrument, PGUpdate
 
45
    Used to build Python in Release configuration using PGO, which
 
46
    requires Professional Edition of Visual Studio.  See the "Profile
 
47
    Guided Optimization" section below for more information.  Build
 
48
    output from each of these configurations lands in its own
 
49
    sub-directory of this directory.  The official Python releases are
 
50
    built using these configurations.
 
51
Release
 
52
    Used to build Python as it is meant to be used in production
 
53
    settings, though without PGO.
 
54
 
 
55
 
 
56
Legacy support
 
57
--------------
 
58
 
 
59
You can find build directories for older versions of Visual Studio and
 
60
Visual C++ in the PC directory. The legacy build directories are no
 
61
longer actively maintained and may not work out of the box.
 
62
 
 
63
Currently, the only legacy build directory is PC\VS9.0, for Visual
 
64
Studio 2008 (9.0).
 
65
 
 
66
 
 
67
C Runtime
 
68
---------
 
69
 
 
70
Visual Studio 2010 uses version 10 of the C runtime (MSVCRT10).  The
 
71
executables no longer use the "Side by Side" assemblies used in previous
 
72
versions of the compiler.  This simplifies distribution of applications.
 
73
 
 
74
The run time libraries are available under the VC/Redist folder of your
 
75
Visual Studio distribution. For more info, see the Readme in the
 
76
VC/Redist folder.
 
77
 
 
78
 
 
79
Sub-Projects
 
80
------------
 
81
 
 
82
The CPython project is split up into several smaller sub-projects which
 
83
are managed by the pcbuild.sln solution file.  Each sub-project is
 
84
represented by a .vcxproj and a .vcxproj.filters file starting with the
 
85
name of the sub-project.  These sub-projects fall into a few general
 
86
categories:
 
87
 
 
88
The following sub-projects represent the bare minimum required to build
 
89
a functioning CPython interpreter.  If nothing else builds but these,
 
90
you'll have a very limited but usable python.exe:
 
91
pythoncore
 
92
    .dll and .lib
 
93
python
 
94
    .exe
 
95
kill_python
 
96
    kill_python.exe, a small program designed to kill any instances of
 
97
    python(_d).exe that are running and live in the build output
 
98
    directory; this is meant to avoid build issues due to locked files
 
99
make_buildinfo, make_versioninfo
 
100
    helpers to provide necessary information to the build process
 
101
 
 
102
These sub-projects provide extra executables that are useful for running
 
103
CPython in different ways:
 
104
pythonw
 
105
    pythonw.exe, a variant of python.exe that doesn't open a Command
 
106
    Prompt window
 
107
pylauncher
 
108
    py.exe, the Python Launcher for Windows, see
 
109
        http://docs.python.org/3/using/windows.html#launcher
 
110
pywlauncher
 
111
    pyw.exe, a variant of py.exe that doesn't open a Command Prompt
 
112
    window
 
113
_testembed
 
114
    _testembed.exe, a small program that embeds Python for testing
 
115
    purposes, used by test_capi.py
 
116
 
 
117
These are miscellaneous sub-projects that don't really fit the other
 
118
categories.  By default, these projects do not build in Debug
 
119
configuration:
 
120
_freeze_importlib
 
121
    _freeze_importlib.exe, used to regenerate Python\importlib.h after
 
122
    changes have been made to Lib\importlib\_bootstrap.py
 
123
bdist_wininst
 
124
    ..\Lib\distutils\command\wininst-10.0[-amd64].exe, the base
 
125
    executable used by the distutils bdist_wininst command
 
126
python3dll
 
127
    python3.dll, the PEP 384 Stable ABI dll
 
128
xxlimited
 
129
    builds an example module that makes use of the PEP 384 Stable ABI,
 
130
    see Modules\xxlimited.c
 
131
 
 
132
The following sub-projects are for individual modules of the standard
 
133
library which are implemented in C; each one builds a DLL (renamed to
 
134
.pyd) of the same name as the project:
 
135
_ctypes
 
136
_ctypes_test
 
137
_decimal
 
138
_elementtree
 
139
_hashlib
 
140
_msi
 
141
_multiprocessing
 
142
_overlapped
 
143
_sha3
 
144
_socket
 
145
_testcapi
 
146
_testbuffer
 
147
_testimportmultiple
 
148
pyexpat
 
149
select
 
150
unicodedata
 
151
winsound
 
152
 
 
153
The following Python-controlled sub-projects wrap external projects.
 
154
Note that these external libraries are not necessary for a working
 
155
interpreter, but they do implement several major features.  See the
 
156
"Getting External Sources" section below for additional information
 
157
about getting the source for building these libraries.  The sub-projects
 
158
are:
 
159
_bz2
 
160
    Python wrapper for version 1.0.6 of the libbzip2 compression library
 
161
    Homepage:
 
162
        http://www.bzip.org/
 
163
_lzma
 
164
    Python wrapper for the liblzma compression library, using pre-built
 
165
    binaries of XZ Utils version 5.0.5
 
166
    Homepage:
 
167
        http://tukaani.org/xz/
 
168
_ssl
 
169
    Python wrapper for version 1.0.1e of the OpenSSL secure sockets
 
170
    library, which is built by ssl.vcxproj
 
171
    Homepage:
 
172
        http://www.openssl.org/
 
173
 
 
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.
 
181
 
 
182
    If you like to use the official sources instead of the files from
 
183
    python.org's subversion repository, Perl is required to build the
 
184
    necessary makefiles and assembly files.  ActivePerl is available
 
185
    from
 
186
        http://www.activestate.com/activeperl/
 
187
    The svn.python.org version contains pre-built makefiles and assembly
 
188
    files.
 
189
 
 
190
    The build process makes sure that no patented algorithms are
 
191
    included.  For now RC5, MDC2 and IDEA are excluded from the build.
 
192
    You may have to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if
 
193
    using official sources; the svn.python.org-hosted version is already
 
194
    fixed.
 
195
 
 
196
    The ssl.vcxproj sub-project simply invokes PCbuild/build_ssl.py,
 
197
    which locates and builds OpenSSL.
 
198
 
 
199
    build_ssl.py attempts to catch the most common errors (such as not
 
200
    being able to find OpenSSL sources, or not being able to find a Perl
 
201
    that works with OpenSSL) and give a reasonable error message.  If
 
202
    you have a problem that doesn't seem to be handled correctly (e.g.,
 
203
    you know you have ActivePerl but we can't find it), please take a
 
204
    peek at build_ssl.py and suggest patches.  Note that build_ssl.py
 
205
    should be able to be run directly from the command-line.
 
206
 
 
207
    The ssl sub-project does not have the ability to clean the OpenSSL
 
208
    build; if you need to rebuild, you'll have to clean it by hand.
 
209
_sqlite3
 
210
    Wraps SQLite 3.8.1, which is itself built by sqlite3.vcxproj
 
211
    Homepage:
 
212
        http://www.sqlite.org/
 
213
_tkinter
 
214
    Wraps version 8.6.1 of the Tk windowing system.
 
215
    Homepage:
 
216
        http://www.tcl.tk/
 
217
 
 
218
    Unlike the other external libraries listed above, Tk must be built
 
219
    separately before the _tkinter module can be built. This means that
 
220
    a pre-built Tcl/Tk installation is expected in ..\..\tcltk (tcltk64
 
221
    for 64-bit) relative to this directory.  See "Getting External
 
222
    Sources" below for the easiest method to ensure Tcl/Tk is built.
 
223
 
 
224
 
 
225
Getting External Sources
 
226
------------------------
 
227
 
 
228
The last category of sub-projects listed above wrap external projects
 
229
Python doesn't control, and as such a little more work is required in
 
230
order to download the relevant source files for each project before they
 
231
can be built.  The buildbots must ensure that all libraries are present
 
232
before building, so the easiest approach is to run either external.bat
 
233
or external-amd64.bat (depending on platform) in the ..\Tools\buildbot
 
234
directory from ..\, i.e.:
 
235
 
 
236
    C:\python\cpython\PCbuild>cd ..
 
237
    C:\python\cpython>Tools\buildbot\external.bat
 
238
 
 
239
This extracts all the external sub-projects from
 
240
    http://svn.python.org/projects/external
 
241
via Subversion (so you'll need an svn.exe on your PATH) and places them
 
242
in ..\.. (relative to this directory).
 
243
 
 
244
It is also possible to download sources from each project's homepage,
 
245
though you may have to change the names of some folders in order to make
 
246
things work.  For instance, if you were to download a version 5.0.7 of
 
247
XZ Utils, you would need to extract the archive into ..\..\xz-5.0.5
 
248
anyway, since that is where the solution is set to look for xz.  The
 
249
same is true for all other external projects.
 
250
 
 
251
The external(-amd64).bat scripts will also build a debug build of
 
252
Tcl/Tk, but there aren't any equivalent batch files for building release
 
253
versions of Tcl/Tk currently available.  If you need to build a release
 
254
version of Tcl/Tk, just take a look at the relevant external(-amd64).bat
 
255
file and find the two nmake lines, then call each one without the
 
256
'DEBUG=1' parameter, i.e.:
 
257
 
 
258
The external-amd64.bat file contains this for tcl:
 
259
    nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install
 
260
 
 
261
So for a release build, you'd call it as:
 
262
    nmake -f makefile.vc MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install
 
263
 
 
264
Note that the above command is called from within ..\..\tcl-8.6.1.0\win
 
265
(relative to this directory); don't forget to build Tk as well as Tcl!
 
266
 
 
267
This will be cleaned up in the future; http://bugs.python.org/issue15968
 
268
tracks adding a new tcltk.vcxproj file that will build Tcl/Tk and Tix
 
269
the same way the other external projects listed above are built.
 
270
 
 
271
 
 
272
Building for AMD64
 
273
------------------
 
274
 
 
275
The build process for AMD64 / x64 is very similar to standard builds,
 
276
you just have to set x64 as platform. In addition, the HOST_PYTHON
 
277
environment variable must point to a Python interpreter (at least 2.4),
 
278
to support cross-compilation from Win32.  Note that Visual Studio
 
279
requires either Standard Edition or better, or Express Edition with the
 
280
Windows SDK 64-bit compilers to be available in order to build 64-bit
 
281
binaries.
 
282
 
 
283
 
 
284
Profile Guided Optimization
 
285
---------------------------
 
286
 
 
287
The solution has two configurations for PGO. The PGInstrument
 
288
configuration must be built first. The PGInstrument binaries are linked
 
289
against a profiling library and contain extra debug information. The
 
290
PGUpdate configuration takes the profiling data and generates optimized
 
291
binaries.
 
292
 
 
293
The build_pgo.bat script automates the creation of optimized binaries.
 
294
It creates the PGI files, runs the unit test suite or PyBench with the
 
295
PGI python, and finally creates the optimized files.
 
296
 
 
297
See
 
298
    http://msdn.microsoft.com/en-us/library/e7k32f4k(VS.100).aspx
 
299
for more on this topic.
 
300
 
 
301
 
 
302
Static library
 
303
--------------
 
304
 
 
305
The solution has no configuration for static libraries. However it is
 
306
easy to build a static library instead of a DLL. You simply have to set
 
307
the "Configuration Type" to "Static Library (.lib)" and alter the
 
308
preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may
 
309
also have to change the "Runtime Library" from "Multi-threaded DLL
 
310
(/MD)" to "Multi-threaded (/MT)".
 
311
 
 
312
 
 
313
Visual Studio properties
 
314
------------------------
 
315
 
 
316
The PCbuild solution makes heavy use of Visual Studio property files
 
317
(*.props). The properties can be viewed and altered in the Property
 
318
Manager (View -> Other Windows -> Property Manager).
 
319
 
 
320
The property files used are (+-- = "also imports"):
 
321
 * debug (debug macro: _DEBUG)
 
322
 * pginstrument (PGO)
 
323
 * pgupdate (PGO)
 
324
    +-- pginstrument
 
325
 * pyd (python extension, release build)
 
326
    +-- release
 
327
    +-- pyproject
 
328
 * pyd_d (python extension, debug build)
 
329
    +-- debug
 
330
    +-- pyproject
 
331
 * pyproject (base settings for all projects, user macros like PyDllName)
 
332
 * release (release macro: NDEBUG)
 
333
 * sqlite3 (used only by sqlite3.vcxproj)
 
334
 * x64 (AMD64 / x64 platform specific settings)
 
335
 
 
336
The pyproject property file defines _WIN32 and x64 defines _WIN64 and
 
337
_M_X64 although the macros are set by the compiler, too. The GUI doesn't
 
338
always know about the macros and confuse the user with false
 
339
information.
 
340
 
 
341
 
 
342
Your Own Extension DLLs
 
343
-----------------------
 
344
 
 
345
If you want to create your own extension module DLL (.pyd), there's an
 
346
example with easy-to-follow instructions in ..\PC\example\; read the
 
347
file readme.txt there first.