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

pip-compatiblity: PIP_CONSTRAINT and PIP_CONSTRAINTS are not used, only UV_CONSTRAINT is used #10686

Open
ssbarnea opened this issue Jan 16, 2025 · 2 comments

Comments

@ssbarnea
Copy link

I found the hard way after migrating from pip to uv on few projects that my lock files are no longer working, just because uv pip command seems to ignore presence of PIP_CONSTRAINT or PIP_CONSTRAINTS file and thus failed to lock the dependencies during install.

I tried defining UV_CONSTRAINT and it worked as expected. This is a divergence from the claimed API compatibility. Sadly the documentation page from https://docs.astral.sh/uv/pip/compatibility/#build-constraints does mention the constraints only on build constraints, not also on install.

I do believe that the desirable fix here is to look for environment variables in this order:

  1. UV_CONSTRAINT
  2. PIP_CONSTRAINTS
  3. PIP_CONSTRAINT (quile uncommon name but apparently supported by pip)

Example

❯ UV_CONSTRAINT=.config/constraints.txt uv pip install .[docs] --dry-run
Using Python 3.13.1 environment at: .tox/docs
Resolved 75 packages in 17ms
Would download 1 package
Would uninstall 2 packages
Would install 2 packages
 - ansible-compat==25.0.1.dev0 (from file:///Users/ssbarnea/code/a/ansible-compat/.tox/.tmp/package/22/ansible_compat-25.0.1.dev0-0.editable-py3-none-any.whl)
 + ansible-compat @ file:///Users/ssbarnea/code/a/ansible-compat
 - mkdocs-autorefs==1.3.0
 + mkdocs-autorefs==1.2.0
❯ PIP_CONSTRAINT=.config/constraints.txt uv pip install .[docs] --dry-run
Using Python 3.13.1 environment at: .tox/docs
Resolved 75 packages in 15ms
Would download 1 package
Would uninstall 1 package
Would install 1 package
 - ansible-compat==25.0.1.dev0 (from file:///Users/ssbarnea/code/a/ansible-compat/.tox/.tmp/package/22/ansible_compat-25.0.1.dev0-0.editable-py3-none-any.whl)
 + ansible-compat @ file:///Users/ssbarnea/code/a/ansible-compat
@charliermarsh
Copy link
Member

We don’t respect pip environment variables anywhere, as a rule. The full list of environment variables that affect uv is enumerated here: https://docs.astral.sh/uv/configuration/environment/

@ssbarnea
Copy link
Author

@charliermarsh Maybe it would worth displaying a warning if PIP_CONSTRAINT(S) is found as defined, mentioning the uv will not use it. This could save a good number of hours to those trying to migrate or use both.

As someone that defined these in his user profile, I do face few surprises...

pip='python3 -m uv pip'
pip3='python3 -m uv pip'

ssbarnea added a commit to ssbarnea/tox-uv that referenced this issue Jan 16, 2025
ssbarnea added a commit to ssbarnea/tox-uv that referenced this issue Jan 16, 2025
ssbarnea added a commit to ssbarnea/tox-uv that referenced this issue Jan 16, 2025
ssbarnea added a commit to ssbarnea/tox-uv that referenced this issue Jan 16, 2025
ssbarnea added a commit to ssbarnea/tox-uv that referenced this issue Jan 16, 2025
gaborbernat pushed a commit to tox-dev/tox-uv that referenced this issue Jan 16, 2025
ssbarnea added a commit to ansible/molecule that referenced this issue Jan 20, 2025
ssbarnea added a commit to ansible/molecule that referenced this issue Jan 20, 2025
ssbarnea added a commit to ansible/molecule that referenced this issue Jan 20, 2025
ssbarnea added a commit to ansible/molecule that referenced this issue Jan 20, 2025
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

No branches or pull requests

2 participants