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

--python can't be used when UV_SYSTEM_PYTHON=false #3829

Closed
thejcannon opened this issue May 24, 2024 · 14 comments · Fixed by #3830
Closed

--python can't be used when UV_SYSTEM_PYTHON=false #3829

thejcannon opened this issue May 24, 2024 · 14 comments · Fixed by #3830
Assignees

Comments

@thejcannon
Copy link

thejcannon commented May 24, 2024

👋 I think this is a CLI quirk, but both of this errors for me:

$ UV_SYSTEM_PYTHON=false uv pip install --python .venv/bin/python```

(Our use case is that by default CI uses `UV_SYSTEM_PYTHON` but in certain tests it uses `uv` to make dedicated venvs for the test)
@thejcannon
Copy link
Author

(I assume this is a quirk of the group:

group = "discovery"
)

@thejcannon thejcannon changed the title --python can't be used when system python is _disabled_ --python can't be used when system python is _disabled_ via env var May 24, 2024
@charliermarsh
Copy link
Member

Yes there's no way to support this in Clap. We'd have to remove the group IIRC.

@thejcannon
Copy link
Author

Also note that uv pip install --python .venv/bin/python --no-system works.

Also just scrubbing the env before calling uv works.

@zanieb
Copy link
Member

zanieb commented May 24, 2024

Ah I recently ran into this at tox-dev/tox-uv#57 (comment) too

It would be nice to override it...

@thejcannon
Copy link
Author

@epage 👋 Do you think this is something Clap would reasonably support (some kind of "its only a collision if two in the group are "truthy"")? If not, @charliermarsh you can probably just close this issue as not planned. There's an easy workaround.

(I couldn't tell if this fit in any of the existing issues, like clap-rs/clap#5041 or if multiple plus manual validation was the way to go)

@charliermarsh
Copy link
Member

We ran into it before and I think we ended up removing the group.

@thejcannon thejcannon changed the title --python can't be used when system python is _disabled_ via env var --python can't be used when UV_SYSTEM_PYTHON=false May 24, 2024
@charliermarsh
Copy link
Member

Actually confused because I thought I fixed this in #3000.

@charliermarsh
Copy link
Member

(But clearly I didn't.)

@charliermarsh
Copy link
Member

I'll just remove the group for now. Better experience.

@thejcannon
Copy link
Author

Oh, well also I should point out uv --version gives me uv 0.1.44 (d417daad7 2024-05-14)

@zanieb
Copy link
Member

zanieb commented May 24, 2024

Weird...

❯ uv self update
info: Checking for updates...
success: Upgraded `uv` to v0.2.3! https://github.com/astral-sh/uv/releases/tag/0.2.3
❯ which uv
/Users/zb/.cargo/bin/uv
❯ uv --version
uv 0.2.3 (ce4d862b0 2024-05-24)
❯ uv venv
Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
❯ uv pip install uv
Resolved 1 package in 151ms
Downloaded 1 package in 1.00s
Installed 1 package in 6ms
 + uv==0.2.3
❯ .venv/bin/uv --version
uv 0.2.3 (ce4d862b0 2024-05-24)

edit: Oh, you mean you're actually on an older version :D

@zanieb
Copy link
Member

zanieb commented May 24, 2024

Definitely not fixed on the latest version though

❯ UV_SYSTEM_PYTHON=1 uv pip install --python .venv anyio
error: the argument '--python <PYTHON>' cannot be used with '--system'

Usage: uv pip install --python <PYTHON> <PACKAGE|--requirement <REQUIREMENT>|--editable <EDITABLE>|--unstable-uv-lock-file <UNSTABLE_UV_LOCK_FILE>>

For more information, try '--help'.

@thejcannon
Copy link
Author

Yeah I just wanted to get ahead of "oh maybe Josh is using an older version 😂 "

(I should type more words in my comments 🤔 )

charliermarsh added a commit that referenced this issue May 24, 2024
## Summary

Allows, e.g., `UV_SYSTEM_PYTHON=false uv pip install --python
.venv/bin/python`.

This was intended to work after fixing
#3000, but I think I misdiagnosed
the scope when closing that issue, and the linked PR there only fixed
some _other_ problems around index URLs.

The only thing we really lose here is we no longer error when
`--break-system-packages` is provided without `--system`, but we can
enforce that elsewhere if we want.

Closes #3829.
@epage
Copy link

epage commented May 24, 2024

For context, clap doesn't consider there to be a conflict for default values, only explicit user values. Environment variables are a weird middle ground that we currently treat as user values which cause problems like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants