I’ve been building Python from source, on Windows, and having some success using custom versions of dependencies.
The only remaining dependency that’s providing me with ‘fun’ is xz (lzma).
It seems the Python build scripts expect xz’s source package to supply .vcxproj files, and until recently it did that. However in the version of xz we’re using, 5.6.2 the project files are removed.
A simple CMake builds xz successfully from the source package, but build.bat and chums don’t do that because v5.2.5 Just Works ™.
It seems as though the build of xz is “all or nothing”: the build scripts build xz, and later link what they built to create the PYD file.
I’m wondering whether there’s a technique I can use so that I build xz from source using CMake, and tell the build scripts where to pick up the output of that build. That’s roughly what I’ve done with other dependencies (eg zlib, tcl, openssl, ffi).
It’s been a few months since I’ve looked at any CMake, but aren’t .vcxproj files produced, when the CMake configure stage is run on xz with the MSVC generator (i.e. instead of the Ninja one)?
Thanks for the reply! Yes, running cmake -S . -B . in the xz source root creates a bunch of vcxproj files, and by downloading the custom version of xz, running that cmake command, and pointing the build at that in the msbuild response file I can make the PC build script look at the result of that when it goes to build xz, but I don’t think the cmake setup and the build script’s expectations match, because the build script is using PCBuild\liblzma.vcxproj, rather than the liblzma.vcxproj generated by cmake.
The most success I’ve had so far (you may want to brace yourself) is running cmake setup into the PCbuild directory. That makes the Python build script build lzma successfully, but when it comes to build the PYD it’s missing lzma.h, which is back in the unpacked source tarball. I feel as though I can get past that by finding a way to augment the list of header directories used by Python’s build. Progress!
You’re most welcome. Do the two liblzma.vcxprojs look similar? It’s straightforward to copy files about in CMake, during config or pre/post build, if it really is just that a header file needs to be copied where the Python build machinery expects to find it.
I don’t know how usable it is, but I’m sure I’ve seen a branch or a project, to try and build the Python source tree with CMake instead of the current autoconf/make setup.