I would like to propose that the required version of Python for LLDB be bumped from 3.9 to 3.11 or higher.
Motivation
When installing the ARM64 Swift toolchain on Windows, users have to install Python 3.9 ARM64. However, the official Python website does not provide an installer for Python 3.9 ARM64. Therefore, a user installing the Swift toolchain on Windows ARM64 would either have to build Python3.9 from source or install from a third party like Nuget.
The first release of Python for which the official website provides an ARM64 installer is 3.11. Bumping the required version of Python to 3.11 would improve the installation experience for ARM64 Windows users, as they would be able to download the Python installer from the official website.
Blockers
I am not sure what is involved in bumping the required Python version for the toolchain.
Adding an option in the swift GUI installer to install Python 3.9.10 from a bundled version would work and is probably simpler than bumping the minimum required version.
I’m more interested in keeping at the same version of Xcode. If Xcode is bumping to 3.11 then windows would follow suite. Adding support to install python from the installer is interesting, and something that we could do as a post step (that is not bundle the installer, but the URL). One of my hopes is to convert to an online installer by default - it would make the installer exe ~1 MB, so 23MB doesn’t work. I’m happy to review patches for an option to install python.
We have some precedent when it comes to different platforms supporting different versions of Python. At least for Ubuntu, we use whichever Python version is the default for that release. Upstream we have pretty good test coverage for the different Python versions, with some bots running 3.9 (notably the macOS one) and the Linux ones running 3.11 and 3.12.
Personally, I think the lack of an ARM64 installer is sufficiently strong motivation to bump the Windows toolchain to a newer version of Python.
Here is the list of things I can think of that we would have to change in order to update the python version:
Change the Python URLs in build.ps1.
Update the documentation on the Swift website which instructs to install Python 3.9.x on Windows.
I don't think we need to update anything on the Windows ci.swift.org bots, as the Python version is handled by build.ps1, which handles the script.
Consequences on users
One consequence of this change on users is that those who update their toolchain would see the missing python311.dll error message when they run lldb for the first time (if they did not read the changelog). I think the message is clear enough to help them fix the issue.
Adding the Python URL to the Swift installer
The Pythons .nupkg available on Nuget are not installers, they are a zip file of the Python toolchains. In build.ps1 we decompress them in the correct directory to install them.
If we were to install Python through the Swift installer, then we would have to manually edit the PATH and some other logic that the Python installer already handles. At a first glance, this seems to add a lot of complexity to the installer.
We could also build the 3.9.10 installer for ARM64 (if that is supported), host it and add that URL to the Swift installer instead of the Nuget one.
Overall this approach seems more complex than updating the Python version in the docs and build.ps1.
I would rather that we don't diverge from macOS versions on Windows. I think that ARM64 not having the installers is not a big deal - Python has supported Windows ARM64 since 3.9 - we have been building against it since we added support for the platform.
This is a non-change - the same thing occurs with Python39.dll instead.
You wouldn't add the URL you would chain the installer. You should look up how burn does chained installers. This is actually exactly what we are doing with the toolchain today. We chain the toolchain, IDE tools, debugging tools, CLI tools, and the SDKs. This isn't too far removed from today's means of installation, but it does add additional complexity as we would need to include a bit of UI to handle the chaining post installation like other installers do.
But we do diverge on Linux? Is that what I read above?
Having lived this for the last year working on SwiftPM for Windows it is a horrible user experience trying to get a python that works, at least for those of us using ARM Windows trying to target all our platforms from a single device.
I also use Windows on ARM64 devices (albeit not ASi). I would be open to someone extending the installer to (optionally) chain the Python installation into the Swift toolchain installer. I don't think that requires diverging on the version here.
I think that we came to a compromise that seems to possibly resolve the issue in a supportable way.
we need to get CI coverage for LLDB on Windows on both llvm-project and swift
we would want to continue to ensure that the python version are the same across amd64 and arm64 Windows
we would want to ideally chain the installation via the installer.
The official LLVM releases use Python 3.10, and so it is preferable that we use Python 3.10 as well if we bump. Fortunately, python.org has a embedded python for ARM64 and AMD64 at 3.10.1.
We could repackage the embedded python as a MSI and add that as an optional component in the installer. This would add an additional ~10MB to the installer and would be an opt-in for the user.
Going forward then, we would tie ourselves to the python version that llvm.org uses on the stable branch that we build from.
For completeness, I just wanted to note that historically our (swift.org) stable branches are not necessarily in sync with any LLVM stable branches. But I understand the desire to use a Python version that has gotten some living on in LLDB outside of the Swift community.
This issue doesn’t seem to be very Swift specific as it would also affect non-swift windows lldb users, it might be worth pitching bumping the python required version in the llvm discourse directly.
Also have we considered the implications of diverging both the upstream version and the swift fork ? I’m concerned it might introduce python code divergence as well, because of deprecated APIs on newer versions of python for instance.