Skip to content
euroargodevPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

hello_uv

A simple Python project to learn how to use uv for dependency management, testing, and CI.

1. Create the project

uv init hello_uv
cd hello_uv

2. Test the entry point

uv run hello-uv

Runs the project.

3. Add development dependencies

uv add --dev pytest

Adds pytest to the dev dependency group.

4. Add project dependencies

uv add xarray numpy requests

Adds dependencies required by the project.

5. Run tests

uv run pytest

Runs the tests using the project's environment.

6. GitHub Actions CI

Created a workflow in .github/workflows/ci.yml to install dependencies, run tests and build the package.

7. CI matrix

Tested the project on multiple operating systems and Python versions:

  • OS: Ubuntu, Windows, macOS
  • Python: 3.12, 3.13

Results: all 6 jobs passed.

8. Build the package

uv build

Creates 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.whl

The wheel contains the package source code and metadata, but not the dependencies themselves.

9. Create a separate user environment

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/activate

10. Install the package

Install the wheel in the new environment:

uv pip install ../hello_uv/dist/hello_uv-0.1.0-py3-none-any.whl

Observations:

  • hello_uv and its runtime dependencies (xarray, numpy, requests) are installed.
  • Transitive dependencies are installed automatically.
  • Development dependencies such as pytest are not installed.

11. Test the installed package

python -c "from hello_uv import hello_world; print(hello_world())"

Result:

Hello, World!

12. Key takeaways

  • uv build: builds the package using uv_build.
  • uv add: adds a dependency to a project and updates pyproject.toml and uv.lock.
  • uv sync: synchronizes the project environment with its lockfile.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages