From e11c9070ce02e79a0a008db60f30b7034c8ab8cd Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Fri, 30 Apr 2021 11:10:54 +0100 Subject: [PATCH] Add a cross-link between the CPP discussion and the FAQ entry. --- docs/cpp_standards.md | 4 +++- docs/faq.md | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/cpp_standards.md b/docs/cpp_standards.md index fa26dfc7..137872cb 100644 --- a/docs/cpp_standards.md +++ b/docs/cpp_standards.md @@ -30,7 +30,9 @@ For more details see https://en.cppreference.com/w/cpp/compiler_support, https:/ ## Windows and Python 2.7 -Visual C++ for Python 2.7 does not support modern C++ standards (i.e., C++11 and later). When building on Appveyor, you will need to either use the "Visual Studio 2017" or "Visual Studio 2019" image, but Python 2.7 is not supported on these images - skip it by setting `CIBW_SKIP=cp27-win*`. +In previous years, Microsoft distributed a compiler toolchain called 'Visual C++ for Python 2.7', which was a distribution of MSVC 9 that was created to make it easier to build Python 2.7 extensions on Windows, because it was fully compatible with the toolchain that built Python 2.7. + +This toolchain does not support modern C++ standards (i.e., C++11 and later). And it is hard to find this toolchain these days, since Microsoft have stopped distributing it. So, by default, cibuildwheel does not attempt to build Python 2.7 extensions on Windows. There is an optional workaround for this, though: the pybind11 project argues and shows that it is [possible to compile Python 2.7 extension with a newer compiler](https://pybind11.readthedocs.io/en/stable/faq.html#working-with-ancient-visual-studio-2008-builds-on-windows) and has an example project showing how to do this: https://github.com/pybind/python_example. The main catch is that a user might need to install [a newer "Microsoft Visual C++ Redistributable"](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads), since the newer C++ standard library's binaries are not included by default with the Python 2.7 installation. diff --git a/docs/faq.md b/docs/faq.md index 223d913e..b1b6bb48 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -155,9 +155,16 @@ To override, you need to have a modern compiler toolchain activated, and set `DI run: | echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV echo "MSSdk=1" >> $GITHUB_ENV + + # invoke cibuildwheel... ``` -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). +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][]. You also need to be [a bit careful][] in designing your extension; some major binding tools like pybind11 do this for you. + +More on setting a custom Windows toolchain in our docs on modern C++ standards [here](cpp_standards.md#windows-and-python-27). + +[Visual C++ Redistributable]: https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0 +[a bit careful]: https://pybind11.readthedocs.io/en/stable/faq.html#working-with-ancient-visual-studio-2008-builds-on-windows ### Building packages with optional C extensions