python-build-standalone
python-build-standalone copied to clipboard
MUSL distributions lacking proper interpreter information
The following illustrates that for some reason the standalone distribution's pip does not consider MUSL wheels and will download the source distribution:
docker run --rm -d --name builder python:alpine sleep infinity
docker exec builder ash -c "apk update && apk add curl"
docker exec builder curl -LO https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz
docker exec builder tar xzf cpython-3.12.3+20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz
docker exec builder /python/bin/python -m pip install uv
I then got the idea to try installing with UV itself but that also doesn't work (but of course itself installs properly with the system Python): https://github.com/astral-sh/uv/issues/3486
I am interested in what packaging._get_musl_version is returning for the executable, and where it's failing.
$ docker exec builder /python/bin/python -m pip install -q packaging
$ docker exec builder /python/bin/python -c "from packaging._musllinux import _get_musl_version;print(_get_musl_version('/python/bin/python'))"
None
Based on its description, could it be because the distribution is statically compiled i.e. https://github.com/indygreg/python-build-standalone/issues/86?
https://github.com/indygreg/python-build-standalone/issues/218#issuecomment-1962753448:
If PEP 656 had been around when I created this project, I may have just made musl libc dynamic by default.
I think this effectively a duplicate of https://github.com/indygreg/python-build-standalone/issues/86, we need dynamically linked musl builds for python-build-standalone to be usable on alpine.
I know it was from before your time but do you know why the original decision opted for static? I don't quite understand the benefit.
I believe it was a requirement for PyOxidizer which was the motivating force behind the project in the first place (I may be wrong) -- it's similar to https://github.com/indygreg/python-build-standalone/issues/221.
See https://github.com/astral-sh/uv/pull/2382 for a (currently failing) test on the uv side
Fixed in #541