-
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
Ability to force distutils as installation scheme backend even on Python 3.10 #10647
Comments
From the suggestion, I'm assuming a private environment variable would not be good enough, and an interpreter-wide setup is needed instead? I guess the Edit: Or maybe we could use the no-manylinux approach? Fedora can put an empty |
We would need to set the environment variable when sysconfig is imported. It might possibly work, but setting/reading an attribute seems like a saner thing to do. |
I can live with that approach as well.
However, we have no trouble patching sysconfig at all. One advantage is that it allows patching in both directions. |
Could you explain this a bit? What would the other direction be? |
I mean this:
This is also possible to achieve with |
I see, that makes sense. A private attribute is best then. |
I am preparing a Python build for Fedora 35 that sets this attribute and will test if it works as expected. Will submit a draft PR shorty, and later figure out the best approach to make this tested. |
…_PIP_USE_SYSCONFIG Fixes pypa#10647
This issue also affects Debian. Consider this simple Dockerfile:
emits
The basic bootstrap script for pip doesn't leave pip installed. Edit: I've found I can work around the issue by installing with |
…_PIP_USE_SYSCONFIG Fixes pypa#10647
…_PIP_USE_SYSCONFIG Fixes pypa#10647
…_PIP_USE_SYSCONFIG Fixes pypa#10647
One "can-we-be-stricter" question: Do we want to restrict this escape hatch to certain versions of CPython, like <= 3.11 or <= 3.12 or something like that? The main benefit I see from that is that it'll more clearly communicate that this is something that'll only stay around for a few Python versions. OTOH, I'm also fine with keeping things simple and no having the conditional be overly complicated. :) |
If as pip maintainers you would want to drop distutils support earlier than Python, or at the same planned release, even if it gets postponed in Python, than it makes kinda sense. OTOH my idea was that when this is set and distutils is gone, it will blow up anyway. |
For Fedora, we only need this in 3.10. |
I imagine we can't drop distutils support before we drop 3.9 support anyway, and by the time that happens Python should be on 3.14 if the current schedule is kept. |
…_PIP_USE_SYSCONFIG Fixes pypa#10647
…_PIP_USE_SYSCONFIG Fixes pypa#10647
What's the problem this feature will solve?
Hello, as you might already know from discussions in https://discuss.python.org/t/pep-632-deprecate-distutils-module/5134/120, in Fedora Linux, we patch our Python to install packages to
/usr/local
prefix by default. This has been historically done by patchingdistutils.command.install
and recently changed to patchingsysconfig._INSTALL_SCHEMES
.I couldn't be happier with pip's move towards the
sysconfig
way, as it makes everything nicer at the end and allows us to get rid of distutils once for all, as distutils is riddled with traps.I see that pip made a considerable choice here and only changes the behavior in Python 3.10+. However, this puts us (the Fedora's Python maintainers) into an unfortunate situation:
sysconfig
in Fedora Linux 36+We realized along the way that the change is not 100% backward compatible and it uncovered several weird bugs in various programs, for example:
Unfortunately, when pip 21.3 was released, Fedora Linux 35 was already beyond code freeze and stability guarantees apply now. As much as I would like to do this change in Fedora Linux 35 as well, I have not found a way to do it that's not potentially disturbing to our users.
What happens now is that when users of Fedora Linux 35 use pip to upgrade pip, it'll start installing packages back to the
/usr
prefix, which has the potential to brick their systems. We don't have any data, but my assumption is that users whopip install --upgrade pip
are more likely to actuallysudo pip install
something that'll negatively impact the package manager or a similar tool.pip-installed pip 21.2.3:
pip-installed pip 21.3:
This does not happen for Fedora Linux 33 and Fedora Linux 34, as the "main" Python version si 3.9 there. This does not happen to Fedora Linux 36 users, as we patch
sysconfig
and hence our setup is compatible with pip's decision.Now, I am not asking you to revert this decision. I am not asking to postpone it to Python 3.11 either. I would merely like to have a way for the Python interpeter to tell pip "hey, I am not ready for this just yet, please use distutils". We would then be able to do this.
Note that we cannot "simply" patch the pip we ship, because it's the upstream pip that the users will likely to install.
Describe the solution you'd like
In here:
https://github.com/pypa/pip/blob/21.3.1/src/pip/_internal/locations/__init__.py#L48
I'd like to be able to able to inject an additional condition that would allow us to use distutils for a bit more time. Something like this:
That way, we could set
sysconfig._PIP_USE_SYSCONFIG = False
in Python 3.10 on Fedora 35.We could also set
sysconfig._PIP_USE_SYSCONFIG = True
in Python 3.9 on Fedora 36+ if we would like to have that experience unified across our interpreters.Alternative Solutions
EDIT: See an alternate solution in #10647 (comment)
An alternate solution is to document this more heavily and discourage users to use
sudo pip
, but we already do this and it doesn't work :(Additional context
Fedora's downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2014513
Code of Conduct
Thank you for considering this. I am willing to add the code if we agree on the behavior.
The text was updated successfully, but these errors were encountered: