• Home
Name Date Size #Lines LOC

..--

Directory.Build.propsD04-Jul-2025249 53

Directory.Build.targetsD04-Jul-2025245 53

_asyncio.vcxprojD04-Jul-20254.3 KiB110109

_asyncio.vcxproj.filtersD04-Jul-2025733 2121

_bz2.vcxprojD04-Jul-20255.3 KiB128128

_bz2.vcxproj.filtersD04-Jul-20252.1 KiB5959

_ctypes.vcxprojD04-Jul-20255 KiB124123

_ctypes.vcxproj.filtersD04-Jul-20251.5 KiB4444

_ctypes_test.vcxprojD04-Jul-20254.4 KiB112112

_ctypes_test.vcxproj.filtersD04-Jul-20251,021 2929

_decimal.vcxprojD04-Jul-20258 KiB164163

_decimal.vcxproj.filtersD04-Jul-20255.3 KiB134133

_elementtree.vcxprojD04-Jul-20255.7 KiB136135

_elementtree.vcxproj.filtersD04-Jul-20253.2 KiB8686

_freeze_module.vcxprojD04-Jul-202525 KiB491476

_freeze_module.vcxproj.filtersD04-Jul-202519.4 KiB571568

_hashlib.vcxprojD04-Jul-20254.5 KiB116115

_hashlib.vcxproj.filtersD04-Jul-2025731 2121

_lzma.vcxprojD04-Jul-20255 KiB123122

_lzma.vcxproj.filtersD04-Jul-2025730 2121

_multiprocessing.vcxprojD04-Jul-20254.7 KiB118118

_multiprocessing.vcxproj.filtersD04-Jul-20251.1 KiB3232

_overlapped.vcxprojD04-Jul-20254.5 KiB114114

_overlapped.vcxproj.filtersD04-Jul-2025729 2121

_queue.vcxprojD04-Jul-20254.3 KiB110109

_queue.vcxproj.filtersD04-Jul-2025731 2121

_socket.vcxprojD04-Jul-20254.6 KiB117117

_socket.vcxproj.filtersD04-Jul-20251,005 2929

_sqlite3.vcxprojD04-Jul-20255.9 KiB138138

_sqlite3.vcxproj.filtersD04-Jul-20252.7 KiB7777

_ssl.vcxprojD04-Jul-20254.9 KiB123122

_ssl.vcxproj.filtersD04-Jul-2025836 2424

_testbuffer.vcxprojD04-Jul-20254.3 KiB109109

_testbuffer.vcxproj.filtersD04-Jul-2025730 2121

_testcapi.vcxprojD04-Jul-20256.4 KiB147146

_testcapi.vcxproj.filtersD04-Jul-20254.4 KiB121120

_testclinic.vcxprojD04-Jul-20254.4 KiB111110

_testclinic.vcxproj.filtersD04-Jul-2025730 2121

_testclinic_limited.vcxprojD04-Jul-20254.3 KiB109109

_testclinic_limited.vcxproj.filtersD04-Jul-2025740 2221

_testconsole.vcxprojD04-Jul-20254.5 KiB115115

_testconsole.vcxproj.filtersD04-Jul-2025919 2323

_testembed.vcxprojD04-Jul-20254.4 KiB112112

_testembed.vcxproj.filtersD04-Jul-2025923 2323

_testimportmultiple.vcxprojD04-Jul-20254.4 KiB111110

_testimportmultiple.vcxproj.filtersD04-Jul-2025738 2121

_testinternalcapi.vcxprojD04-Jul-20255 KiB121120

_testinternalcapi.vcxproj.filtersD04-Jul-20251.1 KiB3130

_testlimitedcapi.vcxprojD04-Jul-20255.6 KiB131130

_testlimitedcapi.vcxproj.filtersD04-Jul-20251.8 KiB3736

_testmultiphase.vcxprojD04-Jul-20254.5 KiB115115

_testmultiphase.vcxproj.filtersD04-Jul-2025927 2323

_testsinglephase.vcxprojD04-Jul-20254.5 KiB116115

_testsinglephase.vcxproj.filtersD04-Jul-2025927 2423

_tkinter.vcxprojD04-Jul-20255.9 KiB137137

_tkinter.vcxproj.filtersD04-Jul-2025832 2424

_uuid.vcxprojD04-Jul-20254.5 KiB115115

_uuid.vcxproj.filtersD04-Jul-2025804 2222

_wmi.vcxprojD04-Jul-20254.7 KiB119119

_wmi.vcxproj.filtersD04-Jul-2025800 2222

_zoneinfo.vcxprojD04-Jul-20254.3 KiB110109

_zoneinfo.vcxproj.filtersD04-Jul-2025728 2121

blurb.batD04-Jul-2025885 2924

build.batD04-Jul-20258.2 KiB199181

build_env.batD04-Jul-202526 21

clean.batD04-Jul-2025133 64

env.batD04-Jul-20251.3 KiB2824

env.ps1D04-Jul-2025105 32

field3.pyD04-Jul-2025974 3617

find_msbuild.batD04-Jul-20252.9 KiB6451

find_python.batD04-Jul-20254.2 KiB9979

fix_encoding.pyD04-Jul-2025952 3722

get_external.pyD04-Jul-20252.3 KiB7865

get_externals.batD04-Jul-20254.4 KiB11899

idle.batD04-Jul-2025713 2822

libffi.propsD04-Jul-20251 KiB2121

liblzma.vcxprojD04-Jul-202514.5 KiB247244

liblzma.vcxproj.filtersD04-Jul-202517.7 KiB435435

openssl.propsD04-Jul-20251.7 KiB3534

openssl.vcxprojD04-Jul-20255.8 KiB139125

pcbuild.projD04-Jul-20257.8 KiB160134

pcbuild.slnD04-Jul-2025130.5 KiB1,6931,692

prepare_libffi.batD04-Jul-20257.4 KiB213175

prepare_ssl.batD04-Jul-20252.1 KiB5947

prepare_ssl.pyD04-Jul-20256.7 KiB204148

prepare_tcltk.batD04-Jul-20252 KiB5744

pyexpat.vcxprojD04-Jul-20254.9 KiB120119

pyexpat.vcxproj.filtersD04-Jul-20251.4 KiB4141

pylauncher.vcxprojD04-Jul-20254.5 KiB115114

pylauncher.vcxproj.filtersD04-Jul-20251 KiB2828

pyproject.propsD04-Jul-202517.3 KiB273241

pyshellext.vcxprojD04-Jul-20254.6 KiB117117

pyshellext.vcxproj.filtersD04-Jul-20251 KiB2828

python.propsD04-Jul-202518.2 KiB285183

python.vcxprojD04-Jul-20257.6 KiB167165

python.vcxproj.filtersD04-Jul-2025850 2726

python3dll.vcxprojD04-Jul-20254.4 KiB110110

python3dll.vcxproj.filtersD04-Jul-2025904 2323

python_uwp.vcxprojD04-Jul-20255.1 KiB129128

python_uwp.vcxproj.filtersD04-Jul-2025848 2626

pythoncore.vcxprojD04-Jul-202540.3 KiB743737

pythoncore.vcxproj.filtersD04-Jul-202557.1 KiB1,6141,613

pythonw.vcxprojD04-Jul-20254.8 KiB115114

pythonw.vcxproj.filtersD04-Jul-2025723 2121

pythonw_uwp.vcxprojD04-Jul-20255.1 KiB129128

pythonw_uwp.vcxproj.filtersD04-Jul-2025850 2626

pywlauncher.vcxprojD04-Jul-20254.5 KiB114114

pywlauncher.vcxproj.filtersD04-Jul-20251 KiB2828

readme.txtD04-Jul-202513.1 KiB334280

regen.targetsD04-Jul-20259.9 KiB184164

rmpyc.pyD04-Jul-2025409 2012

rt.batD04-Jul-20252.9 KiB8473

select.vcxprojD04-Jul-20254.5 KiB113113

select.vcxproj.filtersD04-Jul-2025731 2121

sqlite3.vcxprojD04-Jul-20255.5 KiB122121

sqlite3.vcxproj.filtersD04-Jul-20251.1 KiB3232

tcl.vcxprojD04-Jul-20253.2 KiB7770

tcltk.propsD04-Jul-20254 KiB6049

tk.vcxprojD04-Jul-20253.5 KiB8377

unicodedata.vcxprojD04-Jul-20254.5 KiB113113

unicodedata.vcxproj.filtersD04-Jul-20251.1 KiB3232

urlretrieve.pyD04-Jul-20251.2 KiB4033

venvlauncher.vcxprojD04-Jul-20254.8 KiB119118

venvlauncher.vcxproj.filtersD04-Jul-2025851 2626

venvwlauncher.vcxprojD04-Jul-20254.8 KiB119118

venvwlauncher.vcxproj.filtersD04-Jul-2025851 2626

winsound.vcxprojD04-Jul-20254.5 KiB115115

winsound.vcxproj.filtersD04-Jul-2025796 2222

xxlimited.vcxprojD04-Jul-20254.4 KiB112111

xxlimited.vcxproj.filtersD04-Jul-2025445 1313

xxlimited_35.vcxprojD04-Jul-20254.4 KiB112111

xxlimited_35.vcxproj.filtersD04-Jul-2025450 1413

readme.txt

1Quick Start Guide
2-----------------
3
41.  Install Microsoft Visual Studio 2017 or later with Python workload and
5    Python native development component.
61a. Optionally install Python 3.6 or later.  If not installed,
7    get_externals.bat (via build.bat) will download and use Python via
8    NuGet.
92.  Run "build.bat" to build Python in 32-bit Release configuration.
103.  (Optional, but recommended) Run the test suite with "rt.bat -q".
11
12
13Building Python using Microsoft Visual C++
14------------------------------------------
15
16This directory is used to build CPython for Microsoft Windows on 32- and 64-
17bit platforms.  Using this directory requires an installation of
18Microsoft Visual Studio (MSVC) with the *Python workload* and
19its optional *Python native development* component selected.
20
21Building from the command line is recommended in order to obtain any
22external dependencies. To build, simply run the "build.bat" script without
23any arguments. After this succeeds, you can open the "pcbuild.sln"
24solution in Visual Studio to continue development.
25
26To build an installer package, refer to the README in the Tools/msi folder.
27
28The solution currently supports two platforms.  The Win32 platform is
29used to build standard x86-compatible 32-bit binaries, output into the
30win32 sub-directory.  The x64 platform is used for building 64-bit AMD64
31(aka x86_64 or EM64T) binaries, output into the amd64 sub-directory.
32The Itanium (IA-64) platform is no longer supported.
33
34Four configuration options are supported by the solution:
35Debug
36    Used to build Python with extra debugging capabilities, equivalent
37    to using ./configure --with-pydebug on UNIX.  All binaries built
38    using this configuration have "_d" added to their name:
39    python310_d.dll, python_d.exe, parser_d.pyd, and so on.  Both the
40    build and rt (run test) batch files in this directory accept a -d
41    option for debug builds.  If you are building Python to help with
42    development of CPython, you will most likely use this configuration.
43PGInstrument, PGUpdate
44    Used to build Python in Release configuration using PGO, which
45    requires Premium Edition of Visual Studio.  See the "Profile
46    Guided Optimization" section below for more information.  Build
47    output from each of these configurations lands in its own
48    sub-directory of this directory.  The official Python releases may
49    be built using these configurations.
50Release
51    Used to build Python as it is meant to be used in production
52    settings, though without PGO.
53
54
55Building Python using the build.bat script
56----------------------------------------------
57
58In this directory you can find build.bat, a script designed to make
59building Python on Windows simpler.  This script will use the env.bat
60script to detect either Visual Studio 2017 or 2015, either of
61which may be used to build Python. Currently Visual Studio 2017 is
62officially supported.
63
64By default, build.bat will build Python in Release configuration for
65the 32-bit Win32 platform.  It accepts several arguments to change
66this behavior, try `build.bat -h` to learn more.
67
68
69C Runtime
70---------
71
72Visual Studio 2017 uses version 14.0 of the C runtime (vcruntime140).
73The executables no longer use the "Side by Side" assemblies used in
74previous versions of the compiler.  This simplifies distribution of
75applications.
76
77The run time libraries are available under the redist folder of your
78Visual Studio distribution. For more info, see the Readme in the
79redist folder.
80
81
82Sub-Projects
83------------
84
85The CPython project is split up into several smaller sub-projects which
86are managed by the pcbuild.sln solution file.  Each sub-project is
87represented by a .vcxproj and a .vcxproj.filters file starting with the
88name of the sub-project.  These sub-projects fall into a few general
89categories:
90
91The following sub-projects represent the bare minimum required to build
92a functioning CPython interpreter.  If nothing else builds but these,
93you'll have a very limited but usable python.exe:
94pythoncore
95    .dll and .lib
96python
97    .exe
98
99These sub-projects provide extra executables that are useful for running
100CPython in different ways:
101pythonw
102    pythonw.exe, a variant of python.exe that doesn't open a Command
103    Prompt window
104pylauncher
105    py.exe, the Python Launcher for Windows, see
106        https://docs.python.org/3/using/windows.html#launcher
107pywlauncher
108    pyw.exe, a variant of py.exe that doesn't open a Command Prompt
109    window
110_testembed
111    _testembed.exe, a small program that embeds Python for testing
112    purposes, used by test_capi.py
113
114These are miscellaneous sub-projects that don't really fit the other
115categories:
116_freeze_module
117    _freeze_module.exe, used to regenerate frozen modules in Python
118    after changes have been made to the corresponding source files
119    (e.g. Lib\importlib\_bootstrap.py).
120pyshellext
121    pyshellext.dll, the shell extension deployed with the launcher
122python3dll
123    python3.dll, the PEP 384 Stable ABI dll
124xxlimited
125    builds an example module that makes use of the PEP 384 Stable ABI,
126    see Modules\xxlimited.c
127xxlimited_35
128    ditto for testing the Python 3.5 stable ABI, see
129    Modules\xxlimited_35.c
130
131The following sub-projects are for individual modules of the standard
132library which are implemented in C; each one builds a DLL (renamed to
133.pyd) of the same name as the project:
134 * _asyncio
135 * _ctypes
136 * _ctypes_test
137 * _zoneinfo
138 * _decimal
139 * _elementtree
140 * _hashlib
141 * _multiprocessing
142 * _overlapped
143 * _socket
144 * _testbuffer
145 * _testcapi
146 * _testlimitedcapi
147 * _testinternalcapi
148 * _testclinic
149 * _testclinic_limited
150 * _testconsole
151 * _testimportmultiple
152 * _testmultiphase
153 * _testsinglephase
154 * _tkinter
155 * pyexpat
156 * select
157 * unicodedata
158 * winsound
159
160The following Python-controlled sub-projects wrap external projects.
161Note that these external libraries are not necessary for a working
162interpreter, but they do implement several major features.  See the
163"Getting External Sources" section below for additional information
164about getting the source for building these libraries.  The sub-projects
165are:
166_bz2
167    Python wrapper for version 1.0.8 of the libbzip2 compression library
168    Homepage:
169        http://www.bzip.org/
170_lzma
171    Python wrapper for version 5.2.2 of the liblzma compression library
172    Homepage:
173        https://tukaani.org/xz/
174_ssl
175    Python wrapper for version 3.0 of the OpenSSL secure sockets
176    library, which is downloaded from our binaries repository at
177    https://github.com/python/cpython-bin-deps.
178
179    Homepage:
180        https://www.openssl.org/
181
182    Building OpenSSL requires Perl on your path, and can be performed by
183    running PCbuild\prepare_ssl.bat. This will retrieve the version of
184    the sources matched to the current commit from the OpenSSL branch
185    in our source repository at
186    https://github.com/python/cpython-source-deps.
187
188    To use an alternative build of OpenSSL completely, you should replace
189    the files in the externals/openssl-bin-<version> folder with your own.
190    As long as this folder exists, its contents will not be downloaded
191    again when building.
192
193_sqlite3
194    Wraps SQLite 3.45.3, which is itself built by sqlite3.vcxproj
195    Homepage:
196        https://www.sqlite.org/
197_tkinter
198    Wraps version 8.6.15 of the Tk windowing system, which is downloaded
199    from our binaries repository at
200    https://github.com/python/cpython-bin-deps.
201
202    Homepage:
203        https://www.tcl.tk/
204
205    Building Tcl and Tk can be performed by running
206    PCbuild\prepare_tcltk.bat. This will retrieve the version of the
207    sources matched to the current commit from the Tcl and Tk branches
208    in our source repository at
209    https://github.com/python/cpython-source-deps.
210
211    The two projects install their respective components in a
212    directory alongside the source directories called "tcltk" on
213    Win32 and "tcltk64" on x64.  They also copy the Tcl and Tk DLLs
214    into the current output directory, which should ensure that Tkinter
215    is able to load Tcl/Tk without having to change your PATH.
216
217
218Getting External Sources
219------------------------
220
221The last category of sub-projects listed above wrap external projects
222Python doesn't control, and as such a little more work is required in
223order to download the relevant source files for each project before they
224can be built.  However, a simple script is provided to make this as
225painless as possible, called "get_externals.bat" and located in this
226directory.  This script extracts all the external sub-projects from
227    https://github.com/python/cpython-source-deps
228and
229    https://github.com/python/cpython-bin-deps
230via a Python script called "get_external.py", located in this directory.
231Everything downloaded by these scripts is stored in ..\externals
232(relative to this directory), or the path specified by the EXTERNALS_DIR
233environment variable.
234
235The path or command to use for Python can be provided with the
236PYTHON_FOR_BUILD environment variable. If this is not set, an active
237virtual environment will be used. If none is active, and HOST_PYTHON is
238set to a recent enough version or "py.exe" is able to find a recent
239enough version, those will be used. If all else fails, a copy of Python
240will be downloaded from NuGet and extracted to the externals directory.
241This will then be used for later builds (see PCbuild/find_python.bat
242for the full logic).
243
244It is also possible to download sources from each project's homepage,
245though you may have to change folder names or pass the names to MSBuild
246as the values of certain properties in order for the build solution to
247find them.  This is an advanced topic and not necessarily fully
248supported.
249
250The get_externals.bat script is called automatically by build.bat
251unless you pass the '-E' option.
252
253
254Profile Guided Optimization
255---------------------------
256
257The solution has two configurations for PGO. The PGInstrument
258configuration must be built first. The PGInstrument binaries are linked
259against a profiling library and contain extra debug information. The
260PGUpdate configuration takes the profiling data and generates optimized
261binaries.
262
263The build.bat script has an argument `--pgo` that automate the creation
264of optimized binaries.
265It creates the PGI files, runs the unit test suite with the PGI python,
266and finally creates the optimized files.
267You can customize the job for profiling with `--pgo-job <job>` option.
268
269See
270    https://docs.microsoft.com/en-us/cpp/build/profile-guided-optimizations
271for more on this topic.
272
273
274Static library
275--------------
276
277The solution has no configuration for static libraries. However it is
278easy to build a static library instead of a DLL. You simply have to set
279the "Configuration Type" to "Static Library (.lib)" and alter the
280preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may
281also have to change the "Runtime Library" from "Multi-threaded DLL
282(/MD)" to "Multi-threaded (/MT)".
283
284
285Visual Studio properties
286------------------------
287
288The PCbuild solution makes use of Visual Studio property files (*.props)
289to simplify each project. The properties can be viewed in the Property
290Manager (View -> Other Windows -> Property Manager) but should be
291carefully modified by hand.
292
293The property files used are:
294 * python (versions, directories and build names)
295 * pyproject (base settings for all projects)
296 * openssl (used by projects dependent upon OpenSSL)
297 * tcltk (used by _tkinter, tcl, and tk projects)
298
299The pyproject property file defines all of the build settings for each
300project, with some projects overriding certain specific values. The GUI
301doesn't always reflect the correct settings and may confuse the user
302with false information, especially for settings that automatically adapt
303for different configurations.
304
305Add a new project
306-----------------
307
308For example, add a new _testclinic_limited project to build a new
309_testclinic_limited extension, the file Modules/_testclinic_limited.c:
310
311* In PCbuild/, copy _testclinic.vcxproj to _testclinic_limited.vcxproj,
312  replace RootNamespace value with `_testclinic_limited`, replace
313  `_asyncio.c` with `_testclinic_limited.c`.
314* In PCbuild/, copy _testclinic.vcxproj.filters to
315  _testclinic_limited.vcxproj.filters, edit the list of files in the new file.
316* Open Visual Studio, open PCbuild\pcbuild.sln solution, add the
317  PCbuild\_testclinic_limited.vcxproj project to the solution ("add existing
318  project).
319* Add a dependency on the python project to the new _testclinic_limited
320  project.
321* Save and exit Visual Studio.
322* Add `;_testclinic_limited` to `<TestModules Include="...">` in
323  PCbuild\pcbuild.proj.
324* Update "exts" in Tools\msi\lib\lib_files.wxs file or in
325  Tools\msi\test\test_files.wxs file (for tests).
326* PC\layout\main.py needs updating if you add a test-only extension whose name
327  doesn't start with "_test".
328* Add the extension to PCbuild\readme.txt (this file).
329* Build Python from scratch (clean the solution) to check that the new project
330  is built successfully.
331* Ensure the new .vcxproj and .vcxproj.filters files are added to your commit,
332  as well as the changes to pcbuild.sln, pcbuild.proj and any other modified
333  files.
334