Quick Start Guide-----------------1. Install Microsoft Visual Studio 2017 with Python workload andPython native development component.1a. Optionally install Python 3.6 or later. If not installed,get_externals.bat (via build.bat) will download and use Python viaNuGet.2. Run "build.bat" to build Python in 32-bit Release configuration.3. (Optional, but recommended) Run the test suite with "rt.bat -q".Building Python using Microsoft Visual C++------------------------------------------This directory is used to build CPython for Microsoft Windows NT version6.0 or higher (Windows Vista, Windows Server 2008, or later) on 32 and 64bit platforms. Using this directory requires an installation ofMicrosoft Visual Studio 2017 (MSVC 14.1) with the *Python workload* andits optional *Python native development* component selected. (Forcommand-line builds, Visual Studio 2015 may also be used.)Building from the command line is recommended in order to obtain anyexternal dependencies. To build, simply run the "build.bat" script withoutany arguments. After this succeeds, you can open the "pcbuild.sln"solution in Visual Studio to continue development.To build an installer package, refer to the README in the Tools/msi folder.The solution currently supports two platforms. The Win32 platform isused to build standard x86-compatible 32-bit binaries, output into thewin32 sub-directory. The x64 platform is used for building 64-bit AMD64(aka x86_64 or EM64T) binaries, output into the amd64 sub-directory.The Itanium (IA-64) platform is no longer supported.Four configuration options are supported by the solution:DebugUsed to build Python with extra debugging capabilities, equivalentto using ./configure --with-pydebug on UNIX. All binaries builtusing this configuration have "_d" added to their name:python38_d.dll, python_d.exe, parser_d.pyd, and so on. Both thebuild and rt (run test) batch files in this directory accept a -doption for debug builds. If you are building Python to help withdevelopment of CPython, you will most likely use this configuration.PGInstrument, PGUpdateUsed to build Python in Release configuration using PGO, whichrequires Premium Edition of Visual Studio. See the "ProfileGuided Optimization" section below for more information. Buildoutput from each of these configurations lands in its ownsub-directory of this directory. The official Python releases maybe built using these configurations.ReleaseUsed to build Python as it is meant to be used in productionsettings, though without PGO.Building Python using the build.bat script----------------------------------------------In this directory you can find build.bat, a script designed to makebuilding Python on Windows simpler. This script will use the env.batscript to detect either Visual Studio 2017 or 2015, either ofwhich may be used to build Python. Currently Visual Studio 2017 isofficially supported.By default, build.bat will build Python in Release configuration forthe 32-bit Win32 platform. It accepts several arguments to changethis behavior, try `build.bat -h` to learn more.C Runtime---------Visual Studio 2017 uses version 14.0 of the C runtime (vcruntime140).The executables no longer use the "Side by Side" assemblies used inprevious versions of the compiler. This simplifies distribution ofapplications.The run time libraries are available under the redist folder of yourVisual Studio distribution. For more info, see the Readme in theredist folder.Sub-Projects------------The CPython project is split up into several smaller sub-projects whichare managed by the pcbuild.sln solution file. Each sub-project isrepresented by a .vcxproj and a .vcxproj.filters file starting with thename of the sub-project. These sub-projects fall into a few generalcategories:The following sub-projects represent the bare minimum required to builda functioning CPython interpreter. If nothing else builds but these,you'll have a very limited but usable python.exe:pythoncore.dll and .libpython.exeThese sub-projects provide extra executables that are useful for runningCPython in different ways:pythonwpythonw.exe, a variant of python.exe that doesn't open a CommandPrompt windowpylauncherpy.exe, the Python Launcher for Windows, seehttp://docs.python.org/3/using/windows.html#launcherpywlauncherpyw.exe, a variant of py.exe that doesn't open a Command Promptwindow_testembed_testembed.exe, a small program that embeds Python for testingpurposes, used by test_capi.pyThese are miscellaneous sub-projects that don't really fit the othercategories:_freeze_importlib_freeze_importlib.exe, used to regenerate Python\importlib.h afterchanges have been made to Lib\importlib\_bootstrap.pypyshellextpyshellext.dll, the shell extension deployed with the launcherpython3dllpython3.dll, the PEP 384 Stable ABI dllxxlimitedbuilds an example module that makes use of the PEP 384 Stable ABI,see Modules\xxlimited.cThe following sub-projects are for individual modules of the standardlibrary which are implemented in C; each one builds a DLL (renamed to.pyd) of the same name as the project:_asyncio_ctypes_ctypes_test_decimal_elementtree_hashlib_msi_multiprocessing_overlapped_socket_testbuffer_testcapi_testconsole_testimportmultiple_testmultiphase_tkinterpyexpatselectunicodedatawinsoundThe following Python-controlled sub-projects wrap external projects.Note that these external libraries are not necessary for a workinginterpreter, but they do implement several major features. See the"Getting External Sources" section below for additional informationabout getting the source for building these libraries. The sub-projectsare:_bz2Python wrapper for version 1.0.6 of the libbzip2 compression libraryHomepage:http://www.bzip.org/_lzmaPython wrapper for version 5.2.2 of the liblzma compression libraryHomepage:http://tukaani.org/xz/_sslPython wrapper for version 1.1.1c of the OpenSSL secure socketslibrary, which is downloaded from our binaries repository athttps://github.com/python/cpython-bin-deps.Homepage:http://www.openssl.org/Building OpenSSL requires Perl on your path, and can be performed byrunning PCbuild\prepare_ssl.bat. This will retrieve the version ofthe sources matched to the current commit from the OpenSSL branchin our source repository athttps://github.com/python/cpython-source-deps.To use an alternative build of OpenSSL completely, you should replacethe files in the externals/openssl-bin-<version> folder with your own.As long as this folder exists, its contents will not be downloadedagain when building._sqlite3Wraps SQLite 3.28.0.0, which is itself built by sqlite3.vcxprojHomepage:http://www.sqlite.org/_tkinterWraps version 8.6.6 of the Tk windowing system, which is downloadedfrom our binaries repository athttps://github.com/python/cpython-bin-deps.Homepage:http://www.tcl.tk/Building Tcl and Tk can be performed by runningPCbuild\prepare_tcltk.bat. This will retrieve the version of thesources matched to the current commit from the Tcl and Tk branchesin our source repository athttps://github.com/python/cpython-source-deps.The two projects install their respective components in adirectory alongside the source directories called "tcltk" onWin32 and "tcltk64" on x64. They also copy the Tcl and Tk DLLsinto the current output directory, which should ensure that Tkinteris able to load Tcl/Tk without having to change your PATH.Getting External Sources------------------------The last category of sub-projects listed above wrap external projectsPython doesn't control, and as such a little more work is required inorder to download the relevant source files for each project before theycan be built. However, a simple script is provided to make this aspainless as possible, called "get_externals.bat" and located in thisdirectory. This script extracts all the external sub-projects fromhttps://github.com/python/cpython-source-depsandhttps://github.com/python/cpython-bin-depsvia a Python script called "get_external.py", located in this directory.If Python 3.6 or later is not available via the "py.exe" launcher, thepath or command to use for Python can be provided in the PYTHON_FOR_BUILDenvironment variable, or get_externals.bat will download the latestversion of NuGet and use it to download the latest "pythonx86" packagefor use with get_external.py. Everything downloaded by these scripts isstored in ..\externals (relative to this directory).It is also possible to download sources from each project's homepage,though you may have to change folder names or pass the names to MSBuildas the values of certain properties in order for the build solution tofind them. This is an advanced topic and not necessarily fullysupported.The get_externals.bat script is called automatically by build.batunless you pass the '-E' option.Profile Guided Optimization---------------------------The solution has two configurations for PGO. The PGInstrumentconfiguration must be built first. The PGInstrument binaries are linkedagainst a profiling library and contain extra debug information. ThePGUpdate configuration takes the profiling data and generates optimizedbinaries.The build_pgo.bat script automates the creation of optimized binaries.It creates the PGI files, runs the unit test suite or PyBench with thePGI python, and finally creates the optimized files.Seehttp://msdn.microsoft.com/en-us/library/e7k32f4k(VS.140).aspxfor more on this topic.Static library--------------The solution has no configuration for static libraries. However it iseasy to build a static library instead of a DLL. You simply have to setthe "Configuration Type" to "Static Library (.lib)" and alter thepreprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You mayalso have to change the "Runtime Library" from "Multi-threaded DLL(/MD)" to "Multi-threaded (/MT)".Visual Studio properties------------------------The PCbuild solution makes use of Visual Studio property files (*.props)to simplify each project. The properties can be viewed in the PropertyManager (View -> Other Windows -> Property Manager) but should becarefully modified by hand.The property files used are:* python (versions, directories and build names)* pyproject (base settings for all projects)* openssl (used by projects dependent upon OpenSSL)* tcltk (used by _tkinter, tcl, tk and tix projects)The pyproject property file defines all of the build settings for eachproject, with some projects overriding certain specific values. The GUIdoesn't always reflect the correct settings and may confuse the userwith false information, especially for settings that automatically adaptfor diffirent configurations.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。