This repository wants to be a minimalistic example of uv workspace, hosting an app (/src/my_app) and a library (/packages/my_lib) it depends on. Each workspace member can be either an application or a library, and there can be multiple of them: each of them has its own pyproject.toml, but there's a single, global uv.lock lockfile in the root directory.
What is included in this example:
- basic
uvworkspace layout, includingtests - linting with
ruff(optional) Dockerfile(+.dockerignore) to build a Docker image formy_app(optional)Makefiles to streamline the most common operations (optional)
uv venvThis creates a virtual environment in the .venv directory, so you can point your IDE to it.
uv sync # this will only install dependencies found in the current directory's pyproject.toml
uv sync --package my-lib # this will only install dependencies of my-lib
uv sync --all-packages # this will install dependencies of all workspace members# note: these will only report issues, without fixing them
uv run ruff check
uv run ruff format --check
# note: these will report and fix issues
uv run ruff check --fix
uv run ruff formatAssuming that you have a Python file with an if __name__ == "__main__": block called run.py, you can run it with
uv run run.pyNote: pytest must be listed among the dependencies or the following command will not work.
uv run pytest testsuv build # builds current project
uv build --package my-lib # builds a specific packageBuild files are stored in the dist/ directory.
uv publish # will publish all packages found in dist/uv lock # update lockfile (e.g. after manually changing pyproject.toml)
uv lock --check # check if it's still consistent with pyproject.toml