A simple Python project to learn how to use uv for dependency management, testing, and CI.
uv init hello_uv
cd hello_uvuv run hello-uvRuns the project.
uv add --dev pytestAdds pytest to the dev dependency group.
uv add xarray numpy requestsAdds dependencies required by the project.
uv run pytestRuns the tests using the project's environment.
Created a workflow in .github/workflows/ci.yml to install dependencies, run tests and build the package.
Tested the project on multiple operating systems and Python versions:
- OS: Ubuntu, Windows, macOS
- Python: 3.12, 3.13
Results: all 6 jobs passed.
uv buildCreates two distributions in the dist/ directory:
hello_uv-0.1.0.tar.gz: source distribution (sdist).hello_uv-0.1.0-py3-none-any.whl: wheel.
Inspect the wheel content:
unzip -l dist/hello_uv-0.1.0-py3-none-any.whlThe wheel contains the package source code and metadata, but not the dependencies themselves.
Create a new directory outside the project to simulate a user installing the package. (hello_uv_user)
uv venv --python 3.12
source .venv/bin/activateInstall the wheel in the new environment:
uv pip install ../hello_uv/dist/hello_uv-0.1.0-py3-none-any.whlObservations:
hello_uvand its runtime dependencies (xarray,numpy,requests) are installed.- Transitive dependencies are installed automatically.
- Development dependencies such as
pytestare not installed.
python -c "from hello_uv import hello_world; print(hello_world())"Result:
Hello, World!
uv build: builds the package usinguv_build.uv add: adds a dependency to a project and updatespyproject.tomlanduv.lock.uv sync: synchronizes the project environment with its lockfile.