uv and pytest

It took me a while to figure out why uv run pytest wouldn’t work - it wasn’t finding my library!

Turns out:

uv uses the presence of a build system to determine if a project contains a package that should be installed in the project virtual environment. If a build system is not defined, uv will not attempt to build or install the project itself, just its dependencies.

Hatchling gets mentioned a lot of places, so here’s what I added to my pyproject.toml file:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Now my project is a jank one with bare folders, one of which is “collector”, so I added that manually:

[tool.hatch.build.targets.wheel]
packages = ["collector"]

And now it works!



#uv #python #howto