-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a --python
flag to allow installation into arbitrary Python interpreters
#2000
Conversation
0696413
to
4a086a3
Compare
5c527c8
to
02698d2
Compare
Marking as draft, one important thing to fix here when creating environments for isolated builds (hence test failures). I see the problem. |
654bc4c
to
210ac9d
Compare
platlib: platform.venv_site_packages(&venv_root, self.python_tuple()), | ||
scripts: platform.venv_scripts_dir(&venv_root), | ||
data: platform.venv_data_dir(&venv_root), | ||
include: self.sysconfig.include, |
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.
\cc @konstin - I think include
is the same in a venv as not...
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.
Odd, the docs make it look as if should also change.
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.
Which docs? Link please!
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.
https://docs.python.org/3/library/sysconfig.html#installation-paths
But i don't disagree, include
is also an outlier for me:
Paths:
data = "/home/konsti/projects/uv/.venv"
include = "/home/konsti/.pyenv/versions/3.10.13/include/python3.10"
platinclude = "/home/konsti/.pyenv/versions/3.10.13/include/python3.10"
platlib = "/home/konsti/projects/uv/.venv/lib/python3.10/site-packages"
platstdlib = "/home/konsti/projects/uv/.venv/lib/python3.10"
purelib = "/home/konsti/projects/uv/.venv/lib/python3.10/site-packages"
scripts = "/home/konsti/projects/uv/.venv/bin"
stdlib = "/home/konsti/.pyenv/versions/3.10.13/lib/python3.10"
Same with the apt installed python as base:
Paths:
data = "/home/konsti/projects/uv/.venv"
include = "/usr/include/python3.11"
platinclude = "/usr/include/python3.11"
platlib = "/home/konsti/projects/uv/.venv/lib/python3.11/site-packages"
platstdlib = "/home/konsti/projects/uv/.venv/lib/python3.11"
purelib = "/home/konsti/projects/uv/.venv/lib/python3.11/site-packages"
scripts = "/home/konsti/projects/uv/.venv/bin"
stdlib = "/usr/lib/python3.11"
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.
Depends on the build headers I think? There was an issue a while ago with deadsnakes changing them to /usr/local/include
vs canonical /usr/include
the headers had deadsnakes/issues#237
99d1064
to
af8e92f
Compare
7343e80
to
91bff57
Compare
91bff57
to
ea7c370
Compare
Gonna put up some follow-up PRs. Merging for now. |
518e74b contains a test script and a GitHub Actions workflow to install on system python on macOS and Linux. (I tried to get it to work on Windows, but I wasted too much time trying to get GitHub Actions to work.) |
## Summary In #2000, I shipped a regression whereby we stopped writing relative paths for scripts within `data` directories. The net effect here is that we aren't _uninstalling_ binaries in all cases. (This does _not_ apply to entrypoints, only scripts in `data` directories.) Closes #2330. ## Test Plan Most Python packages ship entrypoints, not binaries, so I don't know how to test this cheaply. But I did test it locally by verifying that `uv` is now removed from the `bin` directory after an uninstall.
Hi @charliermarsh , this is a very useful feature, thanks! I have a couple of questions on usage. Q1:
edit: I can't reproduce this on 0.1.22. I checked again after downgrading back to 0.1.21 (where I originally saw the issue) and could no longer reproduce it there either... 🤷 Q2: how do you actually use this feature with
It works with
|
Summary
This PR adds a
--python
flag that allows users to provide a specific Python interpreter into whichuv
should install packages. This would replace theVIRTUAL_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 thebin
andsite-packages
directories, rather than constructing them based on hard-coded expectations for each platform.Closes #1396.
Closes #1779.
Closes #1988.
Test Plan
requests
into a global environment with:cargo run pip install requests --python 'C:\\Users\\crmarsh\\AppData\\Local\\Programs\\Python\\Python3.12\\python.exe
, thenpython
andimport requests
.requests
into a global environment installed via Homebrew with:cargo run pip install requests --python $(which python3.8)
.