-
Notifications
You must be signed in to change notification settings - Fork 99
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
Account for PEP668 in pip invocations #627
Conversation
c132dde
to
fe12d56
Compare
Set the PIP_BREAK_SYSTEM_PACKAGES environment variable anywhere pip is in use to account for PEP668 which would change pip to not allow us to install in the system environment for newer versions of pip.
This looks good, but was just playing with it while testing some other core PEP668 work Matt C and I were doing and tripped over a nasty problem that's only apparent when actually running in a PEP668-marked environment: it doesn't look like It doesn't look like any RHELish OSs are marking things yet (only recent Debian/Ubuntu), but it's easy to fake it up for testing using the following as your base image: FROM fedora:39
RUN touch /usr/lib64/python3.12/EXTERNALLY-MANAGED Build that locally, then use the resultant image as your base in a vanilla EE with the default Python settings, and it'll 💣 hard on So either we'll need to look up, zap (and possibly re-create?) the marker file, not use |
Well that's a bunch of poo... For reference, this builder EE is enough show the error:
|
I have no idea if this is intended behavior, but you can also bypass [root@8f8a1523eade /]# touch /usr/lib64/python3.12/EXTERNALLY-MANAGED
[root@8f8a1523eade /]# python3 -m ensurepip
error: externally-managed-environment
× This environment is externally managed
╰─> The Python environment under /usr is managed externally, and may not be
manipulated by the user. Please use specific tooling from the distributor of
the Python installation to interact with this environment instead.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
[SNIP]
[root@8f8a1523eade /]# python3 -m ensurepip --root /
Looking in links: /tmp/tmpn6uk_n0x
Processing /tmp/tmpn6uk_n0x/pip-23.2.1-py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-23.2.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv |
Ok, using
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm going to verify one more thing to be sure, but after messing around with Much as I hate to say it, I think we're going to want to hide the |
Per internal discussion, going to move the ensurepip call to a new target script to encapsulate future changes that might be needed for non-RHEL distros, and add a flag to disable the call. |
b280399
to
fe2b956
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be able to move/remove the re-declarations of ENV PIP_BREAK_SYSTEM_PACKAGES=1
(one looks unnecessary, the other only for pre-v3), but LGTM!
pip_install
target script to encapsulate the pip install logic. This will be called to install pip in thebase
image, and thus inherited by the other images. For v1 EE schemas, we always copy this script to thebuilder
image and call it since it will be separate frombase
. For v2, we only copypip_install
to the builder image and call it when one is defined.ensurepip
calls from inside target scripts so we can control pip installation external to those scripts. Also, those calls are unnecessary since we install pip in thebase
image (caveat: see the builder image hoops outlined in previous step).skip_pip_install
option to EE schema to manage pip installation.Fixes #604
Fixes #646