Migrate dependency management from pip to uv

- Add a uv workspace at the repository root covering all packages/kaya-* members
- Replace pip-compile requirements files with a committed uv.lock
- Remove redundant per-package dev extras
- Build and publish artifacts with uv build and uv publish in CI
- Update the README with uv sync/run/build commands
This commit is contained in:
woggioni committed 2026-10-21 21:56:08 +08:00
1 parent ea82ac44e9
commit ec056a15b9
17 files changed
+1814 -409

No files matched your search

+35 -39
View File
@@ -17,69 +17,65 @@ This repository is a monorepo for the Kaya framework. The code is split into ind
- **kaya-forwarded** — trusted-proxy `Forwarded`/`X-Forwarded-*` client address resolution (`packages/kaya-forwarded/`)
- **kaya-otel** — OpenTelemetry tracing and metrics (`packages/kaya-otel/`)
Additional `kaya-*` packages can be added as new directories under `packages/`.
Additional `kaya-*` packages can be added as new directories under `packages/`. When adding a new package, also add it to the root `pyproject.toml` dependencies and `[tool.uv.sources]` so `uv sync` installs it.
## Build & run locally
Install dev dependencies:
This project uses [uv](https://docs.astral.sh/uv/) for dependency management. From the repository root:
```bash
pip install --index-url https://gitea.woggioni.net/api/packages/woggioni/pypi/simple --extra-index-url https://pypi.org/simple -r requirements-dev.txt
uv sync
```
Install the packages in development mode:
```bash
pip install -e packages/kaya-core -e packages/kaya-rsgi -e packages/kaya-session -e packages/kaya-session-redis -e packages/kaya-session-memcache -e packages/kaya-oidc -e packages/kaya-openapi -e packages/kaya-cors -e packages/kaya-forwarded -e packages/kaya-otel
```
This creates `.venv`, installs all workspace packages in editable mode, and installs the dev dependency group from `uv.lock`. Use `uv lock` after changing dependencies, and commit the updated `uv.lock`.
Run the example:
```bash
python example/hello.py
uv run python example/hello.py
```
## Tests
```bash
python -m unittest discover -s packages/kaya-core/tests
python -m unittest discover -s packages/kaya-rsgi/tests
python -m unittest discover -s packages/kaya-session/tests
python -m unittest discover -s packages/kaya-session-redis/tests
python -m unittest discover -s packages/kaya-session-memcache/tests
python -m unittest discover -s packages/kaya-oidc/tests
python -m unittest discover -s packages/kaya-openapi/tests
python -m unittest discover -s packages/kaya-cors/tests
python -m unittest discover -s packages/kaya-forwarded/tests
python -m unittest discover -s packages/kaya-otel/tests
uv run python -m unittest discover -s packages/kaya-core/tests
uv run python -m unittest discover -s packages/kaya-rsgi/tests
uv run python -m unittest discover -s packages/kaya-session/tests
uv run python -m unittest discover -s packages/kaya-session-redis/tests
uv run python -m unittest discover -s packages/kaya-session-memcache/tests
uv run python -m unittest discover -s packages/kaya-oidc/tests
uv run python -m unittest discover -s packages/kaya-openapi/tests
uv run python -m unittest discover -s packages/kaya-cors/tests
uv run python -m unittest discover -s packages/kaya-forwarded/tests
uv run python -m unittest discover -s packages/kaya-otel/tests
```
## Static analysis
```bash
mypy -p kaya.core
mypy -p kaya.rsgi
mypy -p kaya.session
mypy -p kaya.session.redis
mypy -p kaya.session.memcache
mypy -p kaya.oidc
mypy -p kaya.openapi
mypy -p kaya.cors
mypy -p kaya.forwarded
mypy -p kaya.otel
uv run mypy -p kaya.core
uv run mypy -p kaya.rsgi
uv run mypy -p kaya.session
uv run mypy -p kaya.session.redis
uv run mypy -p kaya.session.memcache
uv run mypy -p kaya.oidc
uv run mypy -p kaya.openapi
uv run mypy -p kaya.cors
uv run mypy -p kaya.forwarded
uv run mypy -p kaya.otel
```
## Building packages
```bash
python -m build packages/kaya-core
python -m build packages/kaya-rsgi
python -m build packages/kaya-session
python -m build packages/kaya-session-redis
python -m build packages/kaya-session-memcache
python -m build packages/kaya-oidc
python -m build packages/kaya-openapi
python -m build packages/kaya-cors
python -m build packages/kaya-forwarded
python -m build packages/kaya-otel
uv build --package kaya-core --out-dir packages/kaya-core/dist
uv build --package kaya-rsgi --out-dir packages/kaya-rsgi/dist
uv build --package kaya-session --out-dir packages/kaya-session/dist
uv build --package kaya-session-redis --out-dir packages/kaya-session-redis/dist
uv build --package kaya-session-memcache --out-dir packages/kaya-session-memcache/dist
uv build --package kaya-oidc --out-dir packages/kaya-oidc/dist
uv build --package kaya-openapi --out-dir packages/kaya-openapi/dist
uv build --package kaya-cors --out-dir packages/kaya-cors/dist
uv build --package kaya-forwarded --out-dir packages/kaya-forwarded/dist
uv build --package kaya-otel --out-dir packages/kaya-otel/dist
```