uv icon indicating copy to clipboard operation
uv copied to clipboard

Support for `uv pip install --user`

Open Chaz6 opened this issue 1 year ago • 1 comments
trafficstars

uv pip install does not support the flag --user. The help for pip install --user is as follows:-

  --user                      Install to the Python user install directory for your platform. Typically ~/.local/, or
                              %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.)

Chaz6 avatar Feb 17 '24 12:02 Chaz6

Related #1526, we do not allow installation outside of a virtual environment right now.

zanieb avatar Feb 17 '24 19:02 zanieb

For a bit more context beyond tiered-managed-yet-sans-virtualenv academic and enterprise (modified cacerts, PKI trust - not everything can use truststore yet) userspace deployments, this also has a practical use in building Docker containers, which assemble software from multiple ecosystems and/or have some security policies in place (only centrally curated base images can do USER root, all internal build time steps beyond those base images must run as uid >= 1000).

In those situations it's convenient or necessary to be able to COPY --from=python-build /home/<user>/.local/... the local Python eggs across build stages.

Currently one could work around this by using a virtualenv and an entrypoint script to load that virtualenv up.

But there is a tendency towards extremely minimal hardened images (for general open reference check out what Microsoft is doing with the Dotnet chiseled Ubuntu images). These kinds of runtime images do not ship a shell, thus making the entrypoint workaround impossible. That leaves setting the virtualenv up manually via ENV as the main workaround, and that has implementation time ripple effects around templating of containers when doing internal containers at scale (or leaving it as a fragile pile of copy paste snippets, which people either get right, or don't).

In general implementing uv pip install --user will remove a lot of workarounds needed for uv to "just work" across a wider variety of non-happy-path deployment scenarios currently out there.

Rotonen avatar Apr 08 '24 13:04 Rotonen

I'm going to close this in favor of https://github.com/astral-sh/uv/issues/2077 which has a bunch more discussion in it.

zanieb avatar May 17 '24 13:05 zanieb