Package Management with uv¶
This project uses uv as its Python package manager. It replaces pip + requirements.txt with pyproject.toml + uv.lock for reproducible, fast builds.
Prerequisites¶
Install uv on your machine:
Verify:
Project Structure¶
KubeIntellect/
├── pyproject.toml # dependency declarations (edit this, not requirements.txt)
├── uv.lock # auto-generated lock file — commit this, never edit manually
├── .python-version # pins Python version (3.12)
└── .venv/ # local virtual environment — gitignored
First-Time Setup (new machine / fresh clone)¶
That's it. uv reads pyproject.toml and uv.lock, creates .venv/, and installs everything.
Daily Commands¶
Activate the virtual environment (optional)¶
Or skip activation entirely and prefix commands with uv run:
Add a production dependency¶
Add a development-only dependency¶
Remove a dependency¶
Upgrade a specific package¶
Upgrade all packages (within declared version bounds)¶
Dependency Groups¶
Dependencies are split into groups in pyproject.toml:
| Group | Purpose | Installed in Docker prod? |
|---|---|---|
dependencies | Production runtime | Yes |
dev | Testing, linting, local tools | No |
Install only production deps:
Install everything including dev:
Docker¶
The Dockerfile uses uv with these important flags:
| Flag | Meaning |
|---|---|
--frozen | Fail if uv.lock is out of sync with pyproject.toml — catches drift in CI |
--no-dev | Skip dev dependencies (pytest etc.) — keeps the image lean |
--no-install-project | Don't install the project itself, only its dependencies (faster layer cache) |
To rebuild after changing dependencies:
CI / Production Rules¶
- Always commit
uv.lockto git. It is the single source of truth for exact resolved versions. - Never edit
uv.lockby hand. Letuv lockregenerate it. - Never pin with
==inpyproject.toml— use>=floors and let the lock file handle exact pinning. - The Docker build uses
--frozen, so if you changepyproject.tomlwithout runninguv lock, the build will fail intentionally.