-
Notifications
You must be signed in to change notification settings - Fork 760
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
Flag to allow uv pip install
to install into specific environments (that do not necessarily contain uv)
#1396
Comments
I did also encounter this when trying to use uv as a drop in replacement for my pip projects. |
Definitely agree, this is fundamental to allow a single UV installation to be used as a real standalone binary! |
Yes we should support this. Is there a consensus on the name of the flag in other tools? |
pip has the
but |
pip uses I'm not too familiar with pdm, but the Meta since I got confused:
|
A few things:
|
@ofek no, pip will literally run itself in a subprocess using a different interpreter with |
Thanks for linking the code, I didn't realize that's how they chose to implement it! My point still stands in that pip is already running and therefore the previous assertion that it needs to know where to run is not true (except for that implementation detail) but its purpose is rather to get details about the interpreter. Other tools like virtualenv, Hatch and Poetry use a script that returns the environment of a given interpreter:
|
Sorry, I'm still a little bit confused about what your ask is. Note that
This issue really should just be adding a flag that does what the env var already does I don't know if uv handles installing into base python on Windows correctly with the |
|
Okay, I think I see! To summarise:
So I guess if I were uv, I'd figure out what/how I want to do 1374 / 1526 and maybe that determines what should happen here. Most of the demand for those issues is probably stuff like "make official python docker image work" or "make homebrew python work", for which logic equivalent to |
I'm hoping a solution to this would solve an edge case I'm running into. I often have a conda environment with nox that then creates virtualenvs. This leads to both |
I’m planning to work on this next week. I’ll post here with a concrete proposal once I’ve had time to internalize the comments. (Probably something like a |
As far as I can tell from reading the linked Poetry source, apart from adding the arguments to the CLI etc., the main thing that would need to change to support arbitrary Pythons (outside of a virtual environment) is that we'd need to call |
Definitely some things to learn from in the Poetry source: python-poetry/poetry@e8f259a |
sharing one use case of using inside a multi stages docker build, one stage is building/collecting all packages and install them into a /build directory meanwhile I've worked around using those pip flags, by VIRTUAL_ENV=/user/local, and copy all of /user/local between the layers. |
This is the exact use case I also have |
…erpreters (#2000) ## Summary This PR adds a `--python` flag that allows users to provide a specific Python interpreter into which `uv` should install packages. This would replace the `VIRTUAL_ENV=` workaround that folks have been using to install into arbitrary, system environments, while _also_ actually being correct for installing into non-virtual environments, where the bin and site-packages paths can differ. The approach taken here is to use `sysconfig.get_paths()` to get the correct paths from the interpreter, and then use those for determining the `bin` and `site-packages` directories, rather than constructing them based on hard-coded expectations for each platform. Closes #1396. Closes #1779. Closes #1988. ## Test Plan - Verified that, on my Windows machine, I was able to install `requests` into a global environment with: `cargo run pip install requests --python 'C:\\Users\\crmarsh\\AppData\\Local\\Programs\\Python\\Python3.12\\python.exe`, then `python` and `import requests`. - Verified that, on macOS, I was able to install `requests` into a global environment installed via Homebrew with: `cargo run pip install requests --python $(which python3.8)`.
@charliermarsh I don't think the --python solved the equivalent |
@fruch there's also now a new |
|
It looks like
uv
already supports this, I just need to lie aboutVIRTUAL_ENV
.Looking for something like the equivalent of pip's
--prefix
or--python
.The text was updated successfully, but these errors were encountered: