Add uv support for development environment#4049
Conversation
Demo2026-03-24.23-22-30.mp4This is a testing rollout; the CI hasn’t been touched yet. |
lonvia
left a comment
There was a problem hiding this comment.
Finally got around trying this out. It's a very nice solution to #4022, even for the pip users, and uv opens up testing against other python versions.
Having the dependencies in the root pyproject.toml also makes much more sense because development only happens on the full package. The only optional dependencies that are not always development-related are around serving. But even there it makes sense to have different extra groups (see comment on gunicorn). Something to think about separately.
I've added small comments. Let me know what you think about them.
| types-pygments types-pyyaml types-requests types-ujson \ | ||
| types-urllib3 typing-extensions gunicorn falcon starlette \ | ||
| uvicorn mypy osmium aiosqlite mwparserfromhell | ||
| ``` |
There was a problem hiding this comment.
The dependency groups work nicely with pip as well:
~/nominatim-dev-venv/bin/pip install --group dev
Sadly this isn't a complete replacement for the command above because the required dependencies that are defined in the packages are missing. If there isn't a way to pull them from the subpackages automatically, I'm leaning towards adding another dependency group with those requirements. It'd still be a duplication but in contrast to the line above in the documentation it could be tested in the CI to ensure it stays up-to-date.
There was a problem hiding this comment.
I'm leaning towards adding another dependency group with those requirements.
I will argue with that, i dont think it will a good idea to manage dependencies form two files lt might raise ambiguity later.
I would say lets make the root pyproject.toml a proper package (nominatim) that declares nominatim-api and nominatim-db as its dependencies. With this in place,
pip install --group dev .It will does everything in one-shot, Installs nominatim-api and nominatim-db (and their deps) via [project].dependencies and installs all dev tooling via --group dev
There was a problem hiding this comment.
We unfortunately can't have a package "nominatim". The name is already used and I won't to avoid confusion at any cost. I've contacted the owner but with no success so far.
The other thing to note is that for my use-case I don't want nominatim-{api,db} themselves installed in the virtual environment. I just want the dependencies, i.e. a virtualenv with which I can then run the nominatim-cli.py script in place.
Oh well, this is just a nice-to-have. Lets defer it to later.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
I had to pin mypy to <=1.19.1.... As v 1.20 giving false positives locally
Mypy 1.20 changed how it handles attribute access on class objects vs instances also some breaking changes. Refs:
Idk what y recommend for this ? |
|
Those mypy issues are fixed on master. Simply rebase. |
Add a root pyproject.toml that defines a uv workspace over the existing packaging/ directory and declares PEP 735 dependency groups for development tools (test, lint, types, docs, serve). These groups are ignored by pip and only activated when using uv, so the existing virtualenv + pip workflow is unaffected. The 'dev' group includes all sub-groups by default, so 'uv sync' installs everything needed for development in one command.
Add root pyproject.toml with uv workspace configuration - Add [project] section so pip can auto-install nominatim-api and nominatim-db - Add dependency groups (runtime, test, lint, types, docs, serve) for easy setup - Simplify development docs to use 'pip install --group dev .' instead of long package list - Remove gunicorn from serve group (deployment only) - Pin mypy to <=1.19.1 for compatibility with existing code - Add *.egg-info/ to .gitignore With these changes, developers can set up with: - uv: uv sync - pip: pip install --group dev .
ohh my bad :( ... done |
|
Can we go back to the version without a project in the base pyproject.toml? |
|
Pls have a look now... I’ve added the runtime group as y mentioned... Also i noticed that you’ve added the async version of SQLAlchemy in the API deps, so updated the dev docs accordingly.
|
|
Thanks and sorry for the long wait. |

Summary
pyproject.tomlwith uv workspace configuration and dev dependency groups, enabling contributors to use uv as an alternative to the existing virtualenv + pip workflow.How it works
Contributors using uv can set up their env with a single command:
NOTE: uv.lock is in .gitignore as per project policy.... each developer resolves dependencies locally. For more info refer to the thread #4044
AI usage
None
Contributor guidelines (mandatory)