@@ -245,47 +245,80 @@ still build properly).
245
245
Windows
246
246
-------
247
247
248
- For a quick guide to building you can read `this documentation `_ from Victor
249
- Stinner.
250
-
251
- All current versions of Python can be built using Microsoft Visual Studio 2017
252
- or later. You can download
253
- and use any of the free or paid versions of `Visual Studio 2017 `_.
254
-
255
- When installing Visual Studio 2017, select the **Python development ** workload
256
- and the optional **Python native development tools ** component to obtain all of
257
- the necessary build tools. If you do not already have git installed, you can
258
- find git for Windows on the **Individual components ** tab of the installer.
248
+ .. note :: If you are using the Windows Subsystem for Linux (WSL),
249
+ :ref: `clone the repository <checkout >` from a native Windows shell program
250
+ like PowerShell or the ``cmd.exe `` command prompt,
251
+ and use a build of Git targeted for Windows,
252
+ e.g. the `Git for Windows download from the official Git website `_.
253
+ Otherwise, Visual Studio will not be able to find all the project's files
254
+ and will fail the build.
255
+
256
+ For a concise step by step summary of building Python on Windows,
257
+ you can read `Victor Stinner's guide `_.
258
+
259
+ All supported versions of Python can be built
260
+ using Microsoft Visual Studio 2017 or later.
261
+ You can download and use any of the free or paid versions of `Visual Studio `_.
262
+
263
+ When installing it, select the :guilabel: `Python development ` workload
264
+ and the optional :guilabel: `Python native development tools ` component
265
+ to obtain all of the necessary build tools.
266
+ You can find Git for Windows on the :guilabel: `Individual components ` tab
267
+ if you don't already have it installed.
259
268
260
269
.. note :: If you want to build MSI installers, be aware that the build toolchain
261
- for them has a dependency on the Microsoft .NET Framework Version 3.5 (which
262
- may not be configured on recent versions of Windows, such as Windows 10). If
263
- you are building on a recent Windows version, use the Control Panel (Programs
264
- | Programs and Features | Turn Windows Features on or off) and ensure that the
265
- entry ".NET Framework 3.5 (includes .NET 2.0 and 3.0)" is enabled.
270
+ for them has a dependency on the Microsoft .NET Framework Version 3.5
271
+ (which may not be included on recent versions of Windows, such as Windows 10).
272
+ If you are building on a recent Windows version, use the Control Panel
273
+ (:menuselection: `Programs --> Programs and Features --> Turn Windows Features on or off `)
274
+ and ensure that the entry
275
+ :guilabel: `.NET Framework 3.5 (includes .NET 2.0 and 3.0) ` is enabled.
266
276
267
277
Your first build should use the command line to ensure any external dependencies
268
278
are downloaded:
269
279
270
- .. code-block :: dosbatch
280
+ .. code-block :: batch
281
+
282
+ PCbuild\build.bat -c Debug
283
+
284
+ The above command line build uses the ``-c Debug `` argument
285
+ to build in the ``Debug `` configuration,
286
+ which enables checks and assertions helpful for developing Python.
287
+ By default, it builds in the ``Release `` configuration
288
+ and for the 64-bit ``x64 `` platform rather than 32-bit ``Win32 ``;
289
+ use ``-c `` and ``-p `` to control build config and platform, respectively.
290
+
291
+ After this build succeeds, you can open the ``PCbuild\pcbuild.sln `` solution
292
+ in the Visual Studio IDE to continue development, if you prefer.
293
+ When building in Visual Studio,
294
+ make sure to select build settings that match what you used with the script
295
+ (the :guilabel: `Debug ` configuration and the :guilabel: `x64 ` platform)
296
+ from the dropdown menus in the toolbar.
297
+
298
+ .. note ::
299
+
300
+ If you need to change the build configuration or platform,
301
+ build once with the ``build.bat `` script set to those options first
302
+ before building with them in VS to ensure all files are rebuilt properly,
303
+ or you may encouter errors when loading modules that were not rebuilt.
304
+
305
+ Avoid selecting the ``PGInstrument `` and ``PGUpdate `` configurations,
306
+ as these are intended for PGO builds and not for normal development.
307
+
308
+ You can run the build of Python you've compiled with:
271
309
272
- PCbuild\build.bat
310
+ .. code-block :: batch
273
311
274
- After this build succeeds, you can open the ``PCbuild\pcbuild.sln `` solution in
275
- Visual Studio to continue development.
312
+ PCbuild\amd64\python_d.exe
276
313
277
- See the `readme `_ for more details on what other software is necessary and how
278
- to build.
314
+ See the `PCBuild readme `_ for more details on what other software is necessary
315
+ and how to build.
279
316
280
- .. note :: If you are using the Windows Subsystem for Linux (WSL), clone the
281
- repository from a native Windows terminal program like cmd.exe command prompt
282
- or PowerShell as well as use a build of git targeted for Windows, e.g., the
283
- official one from `<https://git-scm.com >`_. Otherwise, Visual Studio will
284
- not be able to find all the project's files and will fail the build.
317
+ .. _Victor Stinner's guide : https://cpython-core-tutorial.readthedocs.io/en/latest/build_cpython_windows.html
318
+ .. _Visual Studio : https://visualstudio.microsoft.com/
319
+ .. _PCBuild readme : https://github.com/python/cpython/blob/main/PCbuild/readme.txt
320
+ .. _Git for Windows download from the official Git website : https://git-scm.com/download/win
285
321
286
- .. _this documentation : https://cpython-core-tutorial.readthedocs.io/en/latest/build_cpython_windows.html
287
- .. _Visual Studio 2017 : https://visualstudio.microsoft.com/
288
- .. _readme : https://github.com/python/cpython/blob/main/PCbuild/readme.txt
289
322
290
323
.. _build-dependencies :
291
324
0 commit comments