Skip to content

uv sync remove custom installed packages #12481

@neolee

Description

@neolee

Summary

Sometime we will install custom packages (wheels) in our project. For example I'm trying spacy for text tokenization and splitting. This spacy requires installing language models (wheels from their repo). Something like:

.venv ❯ uv run spacy download en_core_web_sm 
Collecting en-core-web-sm==3.8.0
  Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl (12.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.8/12.8 MB 15.0 MB/s eta 0:00:00
Installing collected packages: en-core-web-sm
Successfully installed en-core-web-sm-3.8.0
✔ Download and installation successful
You can now load the package via spacy.load('en_core_web_sm')

.venv ❯ uv run spacy download zh_core_web_sm 
Collecting zh-core-web-sm==3.8.0
  Downloading https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.8.0/zh_core_web_sm-3.8.0-py3-none-any.whl (48.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.5/48.5 MB 14.1 MB/s eta 0:00:00
Collecting spacy-pkuseg<2.0.0,>=1.0.0 (from zh-core-web-sm==3.8.0)
  Using cached spacy_pkuseg-1.0.0-cp311-cp311-macosx_15_0_arm64.whl
Requirement already satisfied: numpy<3.0.0,>=2.0.0 in ./.venv/lib/python3.11/site-packages (from spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.2.4)
Requirement already satisfied: srsly<3.0.0,>=2.3.0 in ./.venv/lib/python3.11/site-packages (from spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.5.1)
Requirement already satisfied: catalogue<2.1.0,>=2.0.3 in ./.venv/lib/python3.11/site-packages (from srsly<3.0.0,>=2.3.0->spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.0.10)
Installing collected packages: spacy-pkuseg, zh-core-web-sm
Successfully installed spacy-pkuseg-1.0.0 zh-core-web-sm-3.8.0
✔ Download and installation successful
You can now load the package via spacy.load('zh_core_web_sm')

As you can see in the above for English and Chinese language, spacy download three wheels and install them in my project virtual env.

Now the problem is, all these packages are not registered in the pyproject.toml file. Next time I run uv sync they will be removed automatically.

.venv ❯ uv sync
Resolved 164 packages in 0.35ms
Uninstalled 3 packages in 9ms
 - en-core-web-sm==3.8.0 (from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl)
 - spacy-pkuseg==1.0.0
 - zh-core-web-sm==3.8.0 (from https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.8.0/zh_core_web_sm-3.8.0-py3-none-any.whl)

Any suggestion about this issue?

p.s. I know the --inexact opt can prevent uv from cleaning unknown packages but if I would like to choose specific extra packages to keep and still want the auto cleaning feature of 'uv', how can I do?

Platform

macOS 15.3.2 arm64

Version

uv 0.6.9 (Homebrew 2025-03-20)

Python version

Python 3.11.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions