Skip to content
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

Regression from 0.1.15 to 0.1.16/17 when using --system on some RHEL based Docker images #2353

Closed
alexprengere opened this issue Mar 11, 2024 · 11 comments
Assignees
Labels
bug Something isn't working needs-mre Needs more information for reproduction

Comments

@alexprengere
Copy link

I have a Docker image from a private registry which boils down to:

FROM some_private_registry/rhel:latest

RUN dnf install --assumeyes python3 \
 && dnf install --assumeyes python3-pip

RUN pip install --upgrade uv==0.1.15
RUN uv pip install httpx --system

This works great!
When replacing uv==0.1.15 by uv==0.1.16 or uv==0.1.17, I now have this error:

STEP 4/4: RUN uv pip install httpx --system
error: Failed to list installed packages
  Caused by: failed to read directory `/usr/local/lib/python3.9/site-packages`
  Caused by: No such file or directory (os error 2)
Error: building at STEP "RUN uv pip install httpx --system": while running runtime: exit status 2

Here are a few more details when inspecting the image:

[root@0d3d619df19e app]# python3 -m site
sys.path = [
    '/app',
    '/usr/lib64/python39.zip',
    '/usr/lib64/python3.9',
    '/usr/lib64/python3.9/lib-dynload',
    '/usr/local/lib64/python3.9/site-packages',
    '/usr/lib64/python3.9/site-packages',
    '/usr/lib/python3.9/site-packages',
]
USER_BASE: '/root/.local' (doesn't exist)
USER_SITE: '/root/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

[root@0d3d619df19e app]# python3 -c 'import site; print("\n".join(site.getsitepackages()))'
/usr/local/lib64/python3.9/site-packages
/usr/local/lib/python3.9/site-packages
/usr/lib64/python3.9/site-packages
/usr/lib/python3.9/site-packages

It looks like /usr/local/lib/python3.9/site-packages does not exist.

[root@0d3d619df19e app]# ls /usr/local/lib64/python3.9/site-packages
uv  uv-0.1.15.dist-info
[root@0d3d619df19e app]# ls /usr/local/lib/python3.9/site-packages
ls: cannot access '/usr/local/lib/python3.9/site-packages': No such file or directory

I am not sure why /usr/local/lib64/python3.9/site-packages was not chosen here.
I checked on Fedora, it has a similar layout and the same issue is there.

@charliermarsh
Copy link
Member

I’ll take a look, thanks! The main change between those versions is that we now follow the same logic as pip: for older Python versions or distros that override it, we use distutils instead of site-packages. That’s likely what’s happening here, since you’re pre-3.9, and my guess is distutils is patched in some way by the distro.

Can you check what directory pip installs into?

@charliermarsh
Copy link
Member

Actually, by far the most useful thing would be if you could share a minimal Dockerfile that reproduces this with Fedora or otherwise.

@charliermarsh charliermarsh self-assigned this Mar 11, 2024
@charliermarsh charliermarsh added bug Something isn't working needs-mre Needs more information for reproduction labels Mar 11, 2024
@alexprengere
Copy link
Author

I could not reproduce on Fedora in Docker, so I will focus on RHEL, and open a separate issue for Fedora if I can ever build a MRE.

Here is the MRE for RHEL:

FROM registry.access.redhat.com/rhel7/rhel
RUN python3 -m ensurepip
RUN python3 -m pip install --upgrade uv
RUN uv pip install httpx --system

Then I use podman to build (4.6.2). Thanks!

@charliermarsh
Copy link
Member

Thank you!

@charliermarsh
Copy link
Member

On that I get:

 > [2/4] RUN python3 -m ensurepip:
#5 0.137 /bin/sh: python3: command not found

@charliermarsh
Copy link
Member

I can try to resolve but I would like to make sure I'm using the same system Python install.

@alexprengere
Copy link
Author

My bad, some caching hid this error. I will attempt another MRE (this is a bit non-trivial as my original issue used a private registry with private base images), and I am trying to replicate on publicly available images. Thank you for your patience.

@charliermarsh
Copy link
Member

@alexprengere - No rush, I just want to get it fixed as soon as I'm able to! :)

@charliermarsh
Copy link
Member

I believe this is fixed by #2413 (available in the next release).

@charliermarsh
Copy link
Member

If not, please re-open!

@alexprengere
Copy link
Author

I can confirm the problem is no longer there on uv 0.1.20 🥳 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-mre Needs more information for reproduction
Projects
None yet
Development

No branches or pull requests

2 participants