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

uv pip sync uninstalls uv itself when installed into the virtual env #1631

Closed
Tonius opened this issue Feb 18, 2024 · 2 comments · Fixed by #1649
Closed

uv pip sync uninstalls uv itself when installed into the virtual env #1631

Tonius opened this issue Feb 18, 2024 · 2 comments · Fixed by #1649
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Tonius
Copy link

Tonius commented Feb 18, 2024

Issue description

When creating a new virtual env and installing uv into it, running uv pip sync will cause it to uninstall itself.

This is inconsistent with pip-tools, whose sync command explicitly ignores pip-tools itself, as described here: https://github.com/jazzband/pip-tools?tab=readme-ov-file#example-usage-for-pip-sync

Note: pip-sync will not upgrade or uninstall packaging tools like setuptools, pip, or pip-tools itself.

Example

$ python3.11 -m venv .env

$ . .env/bin/activate

(.env) $ pip install uv

  Collecting uv
    Obtaining dependency information for uv from https://files.pythonhosted.org/packages/d4/2e/4c60d328ffdd0e2dc824ebec08117c8034e3a505b4f58ff900f1c1519791/uv-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
    Downloading uv-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (17 kB)
  Downloading uv-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.1 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 13.6 MB/s eta 0:00:00
  Installing collected packages: uv
  Successfully installed uv-0.1.4

  [notice] A new release of pip is available: 23.2.1 -> 24.0
  [notice] To update, run: pip install --upgrade pip

(.env) $ echo "ruff==0.2.2" > requirements.in

(.env) $ python -m uv pip compile requirements.in --output-file=requirements.txt
  
  Resolved 1 package in 547ms

(.env) $ python -m uv pip sync requirements.txt

  Resolved 1 package in 28ms
  Downloaded 1 package in 465ms
  Uninstalled 1 package in 1ms
  Installed 1 package in 8ms
   + ruff==0.2.2
   - uv==0.1.4

(.env) $ python -m uv pip sync requirements.txt

  .env/bin/python: No module named uv
@zanieb zanieb added the bug Something isn't working label Feb 18, 2024
@zanieb
Copy link
Member

zanieb commented Feb 18, 2024

Yeah we should probably avoid this :)

@zanieb zanieb added the good first issue Good for newcomers label Feb 18, 2024
charliermarsh pushed a commit that referenced this issue Feb 18, 2024
## Summary

Added `uv` to the list of the preserved packages when building the
installer plan. In that case `uv` is not going to be removed when, for
example, using `python -m uv pip sync requirements.txt` when
requirements.txt does not contain `uv`, but `uv` is installed in that
venv.

Closes #1631 

## Test Plan

Got through the example attached to
#1631 and did see the uv deletion
in the output
```
$ python -m uv pip sync requirements.txt
Installed 1 package in 20ms
 + ruff==0.2.2
```
@jasonwashburn
Copy link

Ha...seemed like a good project for the morning...come back to submit PR and it's already fixed/merged. Even the fixes come surprisingly fast. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants