Packaging
I always forget how to set up uv properly so that it allows me to do something like
from agents import ....
├── src/
│ ├── agents/
│ │ └── __init__.py
│ └── client/
│ └── __init__.py
├── test/
└── pyproject.tomlThe answer is modules
[build-system]
requires = ["uv_build>=0.10.0,<0.11.0"]
build-backend = "uv_build"
[tool.uv.build-backend]
module-name = ["agents", "client"]
module-root = "src"Tools
To expose a python function as a tool you need both a script and build backend.
There’s a lot of guides that tell you to use setuptools or hatch a holdover from pre March 2025
when UV created its own build backend - try it first.
[project.scripts]
agent_example = "src.agents.__init__.py:main"
[build-system]
requires = ["uv_build>=0.10.7,<0.11.0"]
build-backend = "uv_build"Then you can run it with uvx agent_example