The Python Windows build manifests everything we non-Windows users expect to see in a Windows build system, and no contact with the reality of how well building on Windows is today in the real world.
Out of the necessity of supporting the most ancient of legacy dos/win/msvc configs, it uses BAT files instead of modern, open-source, cross-platform, POSIX Shell-specification-based Powershell CORE scripts; It is presented as a series of visual studio solution and project files so complex that people are building complex tooling to make simple changes to it like enabling static libraries: python-build-standalone/build.py at 3307e3920cd6cd404629899adadfcf248c5ca992 · indygreg/python-build-standalone (github.com)
As the gap between the oldest and newest supported VS editions grows wider, the PCBuild folder becomes more and more frustrating to everyone, doing proper service to none.
Modern Visual Studios (2017+) treat CMake and Ninja as first-class citizens and ship with them, while CMake Generators have been capable of creating visual studio projects for quite a long time.
I believe there’s a cross-platform advancement opportunity here, to begin migration to a CMake-based spec for building Python.
Modern CMake has come a long way, modern cmake files are a lot more declarative and focused on creating ADGs rather than messes of variables that need regex manipulating.
I still hate cmake, but it does at least do it’s job these days, and it’s MUCH easier to reason about.
Having a modern build-system description, e.g a CMake project, would be a boon to organizations that either want to embed Python, integrate building extensions cross-platform, integrate end-to-end or vendor-testing, etc.
- Maintain autoconf because people already rely on it and for edge-case e.g embedded hardware devs CMake does not support,
- Maintain PCBuild for older windows and msvs version below VS17,
- Introduce an umbrella CMake project for building and/bsd/ios/mac/lin/win etc,
- Indicate that CMake is primarily targetted at non-vestigial development by selecting a CMake version such as 3.16 or 3.18,
- Automate externals-fetching via CMake’s FetchContent or CPM,
If Python were to ship with a well-furnished cmake lists, building it - including fetching externals and building them - would be as simple as:
# MacOS build
ssh mac && cd python && cmake -B /share/mac_build . && cmake --build /share/mac_build && cmake --install /share/mac_build
# Linux build
ssh lin && cd python && cmake -B /share/lin_build . && cmake --build /share/lin_build && cmake --install /share/mac_build
# Windows build (ssh -> powershell)
ssh win && cd python && cmake -B s:/win_build . && cmake --build s:/win_build && cmake --install s:/win_build
# Windows cygwin build
ssh win && cd python && cmake -DCMAKE_TOOLCHAIN_FILE=../cygwin.cmake -B s:/cyg_build . && cmake --build s:/cyg_build && cmake --install s:/cyg_build