Skip to content

Commit 97a7d7d

Browse files
committed
binary-extensions: update Windows instructions
1 parent 8f7d3fe commit 97a7d7d

1 file changed

Lines changed: 20 additions & 37 deletions

File tree

source/guides/packaging-binary-extensions.rst

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -240,43 +240,26 @@ that you have a suitable compiler available. On Windows, Visual C is used to
240240
build the official CPython interpreter, and should be used to build compatible
241241
binary extensions.
242242

243-
Python 2.7 used Visual Studio 2008, Python 3.3 and 3.4 used Visual Studio 2010,
244-
and Python 3.5+ uses Visual Studio 2015 or later. Unfortunately, older versions of
245-
Visual Studio are no longer easily available from Microsoft, so for versions
246-
of Python prior to 3.5, the compilers must be obtained differently if you do
247-
not already have a copy of the relevant version of Visual Studio.
248-
249-
To set up a build environment for binary extensions, the steps are as follows:
250-
251-
For Python 2.7
252-
253-
1. Install "Visual C++ Compiler Package for Python 2.7",
254-
which is available from
255-
`Microsoft's website <https://www.microsoft.com/en-gb/download/details.aspx?id=44266>`__.
256-
2. Use (a recent version of) setuptools in your setup.py (pip will
257-
do this for you, in any case).
258-
3. Done.
259-
260-
For Python 3.4
261-
262-
1. Install "Windows SDK for Windows 7 and .NET Framework 4" (v7.1),
263-
which is available from
264-
`Microsoft's website <https://www.microsoft.com/en-gb/download/details.aspx?id=8279>`__.
265-
2. Work from an SDK command prompt (with the environment variables
266-
set, and the SDK on PATH).
267-
3. Set DISTUTILS_USE_SDK=1
268-
4. Done.
269-
270-
For Python 3.5
271-
272-
1. Install `Visual Studio 2015 Community Edition
273-
<https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx>`__
274-
(or any later version, when these are released).
275-
2. Done.
276-
277-
Note that from Python 3.5 onwards, Visual Studio works in a backward
278-
compatible way, which means that any future version of Visual Studio will
279-
be able to build Python extensions for all Python versions from 3.5 onwards.
243+
Python 2.7 used Visual Studio 2008, and Python 3.5+ uses Visual Studio 2015 or
244+
later; since 2015 Microsoft has kept backward compatibility (with one exception,
245+
listed below). Unfortunately, older versions of Visual Studio are no longer
246+
available from Microsoft, so building for CPython < 3.5 is discouraged. If you do
247+
need to build for older versions, you can set ``DISTUTILS_USE_SDK=1`` and
248+
``MSSdk=1`` to force a the currently activated version of MSVC to be found,
249+
and you should exercize care when designing your extension not to malloc/free
250+
memory across different libraries, avoid relying on changed data structures,
251+
and so on. Tools for generating extension modules usually avoid these things
252+
for you.
253+
254+
To set up a build environment for binary extensions, install
255+
`Visual Studio Community Edition <https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx>`__ - any
256+
recent version is fine.
257+
258+
One caveat; if you use MSVC 2019+, your extension will depend on an "extra"
259+
file, `VCRUNTIME140_1.dll`, in addition to the `VCRUNTIME140.dll` all previous
260+
verisions back to 2015 depend on. This will add an extra requirement to using
261+
your extension on versions of CPython that do not include this extra file; you
262+
can add the compile-time argument ``/d2FH4-`` to avoid this link on 2019+.
280263

281264
Building with the recommended compiler on Windows ensures that a compatible C library
282265
is used throughout the Python process.

0 commit comments

Comments
 (0)