Command `uv pip sync requirements.txt` remove pip in venv create with `uv venv --seed`
Version info (on macOS)
❯ uv --version
uv 0.4.6 (84f25e8cf 2024-09-05)
Content of requirements.in
ruff
Create venv
❯ uv --verbose venv --seed
DEBUG uv 0.4.6
DEBUG Searching for Python interpreter in managed installations or system path
DEBUG Searching for managed installations at `/Users/user/.local/share/uv/python`
DEBUG Found managed installation `cpython-3.12.5-macos-aarch64-none`
DEBUG Found `cpython-3.12.5-macos-aarch64-none` at `/Users/user/.local/share/uv/python/cpython-3.12.5-macos-aarch64-none/bin/python3` (managed installations)
Using Python 3.12.5
Creating virtualenv with seed packages at: .venv
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.12.5
DEBUG Solving with target Python version: >=3.12.5
DEBUG Adding direct dependency: pip*
DEBUG Found fresh response for: https://pypi.org/simple/pip/
DEBUG Searching for a compatible version of pip (*)
DEBUG Selecting: pip==24.2 [compatible] (pip-24.2-py3-none-any.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/d4/55/90db48d85f7689ec6f81c0db0622d704306c5284850383c090e6c7195a5c/pip-24.2-py3-none-any.whl.metadata
DEBUG Tried 1 versions: pip 1
DEBUG Split specific environment resolution took 0.001s
DEBUG Installing in pip==24.2 in /Users/user/Desktop/ppp-project/.venv
DEBUG Requirement already cached: pip==24.2
DEBUG Installing build requirement: pip==24.2
+ pip==24.2
Activate with: source .venv/bin/activate
Generate requirements.txt
❯ uv --verbose pip compile requirements.in -o requirements.txt
DEBUG uv 0.4.6
DEBUG Starting Python discovery for any Python
DEBUG Looking for exact match for request any Python
DEBUG Searching for Python interpreter in managed installations or system path
DEBUG Found `cpython-3.12.5-macos-aarch64-none` at `/Users/user/Desktop/ppp-project/.venv/bin/python3` (active virtual environment)
DEBUG Using Python 3.12.5 interpreter at .venv/bin/python3 for builds
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.12.5
DEBUG Solving with target Python version: >=3.12.5
DEBUG Adding direct dependency: ruff*
DEBUG Found fresh response for: https://pypi.org/simple/ruff/
DEBUG Searching for a compatible version of ruff (*)
DEBUG Selecting: ruff==0.6.4 [preference] (ruff-0.6.4-py3-none-macosx_11_0_arm64.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/a6/fd/8784e3bbd79bc17de0a62de05fe5165f494ff7d77cb06630d6428c2f10d2/ruff-0.6.4-py3-none-macosx_11_0_arm64.whl.metadata
DEBUG Tried 1 versions: ruff 1
DEBUG Split specific environment resolution took 0.004s
Resolved 1 package in 4ms
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
ruff==0.6.4
# via -r requirements.in
Run sync
❯ uv --verbose pip sync requirements.txt
DEBUG uv 0.4.6
DEBUG Searching for Python interpreter in system path
DEBUG Found `cpython-3.12.5-macos-aarch64-none` at `/Users/user/Desktop/ppp-project/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.5 environment at .venv/bin/python3
DEBUG Acquired lock for `.venv`
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.12.5
DEBUG Solving with target Python version: >=3.12.5
DEBUG Adding direct dependency: ruff==0.6.4
DEBUG Found fresh response for: https://pypi.org/simple/ruff/
DEBUG Searching for a compatible version of ruff (==0.6.4)
DEBUG Selecting: ruff==0.6.4 [compatible] (ruff-0.6.4-py3-none-macosx_11_0_arm64.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/a6/fd/8784e3bbd79bc17de0a62de05fe5165f494ff7d77cb06630d6428c2f10d2/ruff-0.6.4-py3-none-macosx_11_0_arm64.whl.metadata
DEBUG Tried 1 versions: ruff 1
DEBUG Split specific environment resolution took 0.004s
Resolved 1 package in 4ms
DEBUG Requirement already cached: ruff==0.6.4
DEBUG Unnecessary package: pip==24.2
DEBUG Uninstalled pip (442 files, 51 directories)
Uninstalled 1 package in 32ms
Installed 1 package in 2ms
- pip==24.2
+ ruff==0.6.4
DEBUG Released lock at `/Users/user/Desktop/ppp-project/.venv/.lock`
I’ll take a look, we special-case this so pip shouldn’t be removed.
I misremembered -- we preserve "seed" packages only if the virtualenv was created by a tool other than uv.
Can uv keep "seed" packages if create venv by uv venv --seed? or add a flag to uv pip sync command?
Yeah we probably should? I'm not sure why we wouldn't want to.
+1 to never remove seed packages by default. I think wanting to sync them is more of an edge case than not wanting it.
We'll need to track this state, presumably in the pyvenv.cfg? We don't currently
❯ uv venv --seed
Using Python 3.11.10
Creating virtualenv with seed packages at: .venv
+ pip==24.2
+ setuptools==74.1.2
+ wheel==0.44.0
Activate with: source .venv/bin/activate
❯ cat .venv/pyvenv.cfg
home = /Users/zb/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/bin
implementation = CPython
uv = 0.4.9
version_info = 3.11.10
include-system-site-packages = false
relocatable = false
prompt = uv
Like, track the fact that we created the env with seed packages there?
I can do that, not too hard.