-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround to fix BPO-43112 #10678
Comments
I think pip should make a symlink so both names work, otherwise this could become dependent on the Python patch version reading the installed copy. This should only be needed for Python < 3.11, as 3.11 should handle this correctly, I would expect. As mentioned, ideally audithwheel should do this, but it can't make symlinks in wheels since CPython never fixed symlinks in zip files. |
I don't quite understand the issue here. PEP 656 defines the tags for MUSL wheels. So when you say "we are distributing broken musllinux_1_1 wheel packages", why is the remedy not simply "don't do that, then"? I'm not being awkward here, I'm completely OK with fixing this issue, but the messages I've seen have been a bit confused, and I don't understand why this is suddenly an issue. The inability to have symlinks in wheels is far from a new issue, and the patch referenced in BPO-43112 (python/cpython#24502) was submitted back in February, well before the musllinux PEP was approved - so why was the PEP submitted for approval if the PR hadn't been accepted? What was the expectation for how people would build musllinux wheels given that bpo-43112 was a known issue at the time (in particular, @tiran linked it in the PEP 656 thread here). As I say, I'm fine with getting a fix for this, but the contract behind musllinux (and the perennial manylinux standard that it's based on) is that wheel producers are responsible for ensuring the wheels are compatible with all environments implied by the tag. How did that break down in this case? |
I believe the problem is that the “non-broken” wheels don’t work on any of the currently released Python versions, so this request is based on an implicit engineering decision to make new wheels from this point on to work on those existing Python versions. The wheel tag is also not technically related to the SOABI issue, because a platform-tagged wheel does not necessarily contain binary (it’s the other way around), and wheels can be built and deployed, it’s only Python is unable to load some code installed from it. I’m wondering though, is it really the best idea to treat this as a bugfix? I also commented the same thought on bpo-43112; the current “wrong” |
Quick visual summary: Python on
Hover, Alpine 3.141 produces2 and expects only this:
For CPython 3.11, this is easy, just produce and read the Footnotes |
@pfmoore The issue comes from Python having been broken for some time in ways that are not captured by the MUSL tag (and not adequately fixed by a new tag). Python distributed in the
on this docker image gets built the manylinux, which creates libraries with
The options to provide wheel packages that work for the whole Python 3.9 and 3.10 lifespan is either to build packages twice as big (and they get chubby pretty quickly already, see pydantic/pydantic#3439) or that the bug is addressed at install time, and pip happens to be in position to do so. |
This definition of “buggy” assumes that
This can arguably be categorises as an Alpine bug instead, because they distribute Python built in a way that can’t load modules built from the official Python distribution. Using the same hypothetical |
There is some confusing around official Python container images on Dockerhub. The official Docker images on Dockerhub are not provided by the Python core team, Python release managers or PSF. They are created by the Docker community. We have no control what goes into the containers and how they are build. |
$ docker run --rm -it alpine:3.14
# apk add python3
...
# python3 -c 'import sysconfig; print(sysconfig.get_config_vars("SOABI"))'
['cpython-39-x86_64-linux-musl'] Is it currently supported to add multiple extensions in a single installed folder? I think that was the idea behind the tagging in the first place; you could have a shared directory accessible by multiple OSs; in this case, if it had worked, this could have been usable by both musl and gnu linux. Not sure how important this is (you can't mix manylinux versions, etc). If not, then calling this "-gnu" isn't necessarily a bug, and Alpine's patching is at fault.
These are not doing any special patching on CPython, only Alpine is, from what I understand. Ether |
Here's the patch: https://git.alpinelinux.org/aports/tree/main/python3/bpo-43112.patch?h=3.14-stable (from https://git.alpinelinux.org/aports/tree/main/python3?h=3.14-stable ) And guessing that's @ncopa maintaining and adding the patch. |
My definition of who is buggy and who is right came from reading the BPO issue, e.g. https://bugs.python.org/issue43112#msg386710 As far as I'm concerned I can let Python and Alpine people decide who is right and who is wrong. The status quo is that, under the manylinux_1_1 tag, different incompatible images can be produced, and the risk is that, with a change of the build tools (manylinux issue), released packages will suddenly stop working (final packager issue). As far as I am concerned, I can see that the
Without either of these reassurances, I cannot conscientiously release psycopg musllinux binary packages, and will stop doing so from the next bugfix release, in order to safeguard my users. |
Edit: Actually, since they don't make extensions, but load via general shared objects, this is invalid. Only ABI3 would be affected, sorry! (And not sure I've seen much of that in the wild) |
I want to also comment on why I seem to oppose a seemingly simple fix to the situation. Wheel is an open standard, and pip is not the only wheel installer. So to properly apply the solution proposed in the top post, we need to add this special clause to the wheel standard and notify all relevant parties. This is much work with longer lasting effect than just a pip change. |
OK, if I'm following this, two different Alpine docker images have Python configured differently? And one, the one that isn't supported by the core Python devs, is applying a behaviour-changing patch that has been submitted to core Python but hasn't been applied there yet. ... and all of this is purely about what string is used to identify a So essentially, the principle in PEP 656, that "the tag promises the wheel works on any mainstream Linux distribution that uses musl version ${MUSLMAJOR}.${MUSLMINOR}" is being violated, and the reason is that the MUSL community are distributing Python builds that make it impossible to satisfy that promise (if we consider "the official python docker image" and "the official alpine docker image" as being two "mainstream Linux distributions that use musl") 🙁 I'm getting less and less comfortable with pip patching over this mess. It's a social and communication issue, that was raised at the time of the PEP 656 discussion, and I flagged in my acceptance of the PEP that making the "play nice with others" approach work would be a key to the success of the PEP.
Yes, it looks like that. And that's (IMO) an issue for the musl community to solve. Frankly, it was pretty much the basis for approving the musllinux PEP, that the community would work together to ensure things worked.
I think that's a reasonable position to take. |
Honestly, me too, in the sense that, if Alpine people are the ones to dictate that they want a If Python decides that |
One minor correction: neither of the two Alpine images are supported by CPython core devs, but different third-party vendors (the Alpine and Docker community, respectively). |
How hard would it be to patch CPython to accept both extensions? I'm not thinking of an upstream python/cpython patch, but just a damage-reduction patch for Alpine 3.14 (and 3.15, which shipped this morning before they noticed this) to be applied to their already-patched Python 3.9 on those platforms. It would just add |
I had in mind to contact the Alpine maintainers to hear from them too: @henryiii has already done it. Thank you for that 🙂 |
We had a call and have a potential path forward. Quick summary:
If we'd notified them a day earlier 3.15 could likely have been delayed and fixed. How does that sound? |
To be clear, the first two bullets are for Alpine, the third for CPython, and the last for packaging folks, right? Not that every party needs to be be involved in every step. |
More to the point, none of this needs any change to pip, is that right? |
Yes to both. No change to pip required. |
Thanks @dvarrazzo and @henryiii for driving this to a clear path for resolution!
So... I know what to do with this issue then! 😛 |
FYI. This is done in Alpine now. |
What's the problem this feature will solve?
In this moment, because of BPO-43112, we are distributing broken musllinux_1_1 wheel packages for Python 3.9 and 3.10, which work on Docker images such as
python:3.9-alpine
but will not work on thealpine
using the system Python.When BPO-43112 will be solved, there will be a situation of incompatibility, resulting in newly built packages not working on the
python-alpine
image, for some time, and not working for current images.Describe the solution you'd like
Pip is in the right place to save the day 🙂 because it could easily rename the broken file on install, if it detects the right conditions (tag
musllinux_1_1
,.so
file suffix mismatching thesysconfig.get_config_vars("SOABI")
) it might simply rename the wrongly named library. It has the file system permission to do so and it would work both to make broken wheels work on new images and fixed wheels to work on old images.Alternative Solutions
A workaround bridge solution of distributing a compatibility symlink (see psycopg/psycopg#161) is hampered by the fact that symlinks in zip files are not handled by the
zipfile
module (https://bugs.python.org/issue18595, https://bugs.python.org/issue27318).Additional context
Code of Conduct
The text was updated successfully, but these errors were encountered: