From 07b87ea651deb1c9f68055f1b3307fd7d251d074 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 27 Apr 2021 19:05:31 +0100 Subject: [PATCH] Add Windows 2.7 FAQ entry. --- docs/faq.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index a43f4ae2..223d913e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -136,6 +136,29 @@ Here's an example GitHub Actions workflow with a job that builds for Apple Silic {% include "../examples/github-apple-silicon.yml" %} ``` +### Windows and Python 2.7 + +Building 2.7 extensions on Windows is difficult, because the VS 2008 compiler that was used for the original Python compilation was discontinued in 2018, and has since been removed from Microsoft's downloads. Most people choose to not build Windows 2.7 wheels, or to override the compiler to something more modern. + +To override, you need to have a modern compiler toolchain activated, and set `DISTUTILS_USE_SDK=1` and `MSSdk=1`. For example, on GitHub Actions, you would add these steps: + +```yaml + - name: Prepare compiler environment for Windows + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - name: Set Windows environment variables + if: runner.os == 'Windows' + shell: bash + run: | + echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV + echo "MSSdk=1" >> $GITHUB_ENV +``` + +cibuildwheel will not try to build 2.7 on Windows unless it detects that the above two variables are set. Note that changing to a more modern compiler will mean your wheel picks up a runtime dependency to a different [Visual C++ Redistributable](https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0). + ### Building packages with optional C extensions `cibuildwheel` defines the environment variable `CIBUILDWHEEL` to the value `1` allowing projects for which the C extension is optional to make it mandatory when building wheels.