@@ -258,48 +258,27 @@ Binary extensions for Windows
258258Before it is possible to build a binary extension, it is necessary to ensure
259259that you have a suitable compiler available. On Windows, Visual C is used to
260260build the official CPython interpreter, and should be used to build compatible
261- binary extensions.
261+ binary extensions. To set up a build environment for binary extensions, install
262+ `Visual Studio Community Edition <https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx >`__
263+ - any recent version is fine.
264+
265+ One caveat: if you use Visual Studio 2019 or later, your extension will depend
266+ on an "extra" file, ``VCRUNTIME140_1.dll ``, in addition to the
267+ ``VCRUNTIME140.dll `` that all previous versions back to 2015 depend on. This
268+ will add an extra requirement to using your extension on versions of CPython
269+ that do not include this extra file. To avoid this, you can add the
270+ compile-time argument ``/d2FH4- ``. Recent versions of Python may include this
271+ file.
272+
273+ Building for Python prior to 3.5 is discouraged, because older versions of
274+ Visual Studio are no longer available from Microsoft. If you do need to build
275+ for older versions, you can set ``DISTUTILS_USE_SDK=1 `` and ``MSSdk=1 `` to
276+ force a the currently activated version of MSVC to be found, and you should
277+ exercise care when designing your extension not to malloc/free memory across
278+ different libraries, avoid relying on changed data structures, and so on. Tools
279+ for generating extension modules usually avoid these things for you.
262280
263- Python 2.7 used Visual Studio 2008, Python 3.3 and 3.4 used Visual Studio 2010,
264- and Python 3.5+ uses Visual Studio 2015 or later. Unfortunately, older versions of
265- Visual Studio are no longer easily available from Microsoft, so for versions
266- of Python prior to 3.5, the compilers must be obtained differently if you do
267- not already have a copy of the relevant version of Visual Studio.
268281
269- To set up a build environment for binary extensions, the steps are as follows:
270-
271- For Python 2.7
272-
273- 1. Install "Visual C++ Compiler Package for Python 2.7",
274- which is available from
275- `Microsoft's website <https://www.microsoft.com/en-gb/download/details.aspx?id=44266 >`__.
276- 2. Use (a recent version of) setuptools in your setup.py (pip will
277- do this for you, in any case).
278- 3. Done.
279-
280- For Python 3.4
281-
282- 1. Install "Windows SDK for Windows 7 and .NET Framework 4" (v7.1),
283- which is available from
284- `Microsoft's website <https://www.microsoft.com/en-gb/download/details.aspx?id=8279 >`__.
285- 2. Work from an SDK command prompt (with the environment variables
286- set, and the SDK on PATH).
287- 3. Set DISTUTILS_USE_SDK=1
288- 4. Done.
289-
290- For Python 3.5
291-
292- 1. Install `Visual Studio 2015 Community Edition
293- <https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx> `__
294- (or any later version, when these are released).
295- 2. Done.
296-
297- Note that from Python 3.5 onwards, Visual Studio works in a backward
298- compatible way, which means that any future version of Visual Studio will
299- be able to build Python extensions for all Python versions from 3.5 onwards.
300-
301- Building with the recommended compiler on Windows ensures that a compatible C library
302- is used throughout the Python process.
303282
304283Binary extensions for Linux
305284---------------------------
0 commit comments