Skip to content

Add uv support for development environment#4049

Merged
lonvia merged 7 commits into
osm-search:masterfrom
Itz-Agasta:uv
Apr 21, 2026
Merged

Add uv support for development environment#4049
lonvia merged 7 commits into
osm-search:masterfrom
Itz-Agasta:uv

Conversation

@Itz-Agasta
Copy link
Copy Markdown
Contributor

@Itz-Agasta Itz-Agasta commented Mar 24, 2026

Summary

  • Add a root pyproject.toml with uv workspace configuration and dev dependency groups, enabling contributors to use uv as an alternative to the existing virtualenv + pip workflow.
  • Add documentation for using uv in the dev environment setup.

How it works

Contributors using uv can set up their env with a single command:

uv sync
# This installs runtime dependencies (from the package pyproject.toml files)
# and all dev tools (pytest, mypy, flake8, mkdocs, etc.) into a local .venv.

# Individual groups can be installed separately:
uv sync --group test --no-dev    # Only test dependencies
uv sync --group docs --no-dev    # Only docs dependencies
uv sync --group serve --no-dev   # Only server dependencies

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)

  • I have adhered to the coding style
  • I have tested the proposed changes
  • I have disclosed above any use of AI to generate code, documentation, or the pull request description

@Itz-Agasta
Copy link
Copy Markdown
Contributor Author

Demo

2026-03-24.23-22-30.mp4

This is a testing rollout; the CI hasn’t been touched yet.

Copy link
Copy Markdown
Member

@lonvia lonvia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/develop/Development-Environment.md Outdated
types-pygments types-pyyaml types-requests types-ujson \
types-urllib3 typing-extensions gunicorn falcon starlette \
uvicorn mypy osmium aiosqlite mwparserfromhell
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@Itz-Agasta Itz-Agasta Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml Outdated
@Itz-Agasta
Copy link
Copy Markdown
Contributor Author

Itz-Agasta commented Apr 4, 2026

I had to pin mypy to <=1.19.1.... As v 1.20 giving false positives locally

image

Not related to uv. i have tested with pip too

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 ?

@lonvia
Copy link
Copy Markdown
Member

lonvia commented Apr 4, 2026

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 .
@Itz-Agasta
Copy link
Copy Markdown
Contributor Author

Those mypy issues are fixed on master. Simply rebase.

ohh my bad :( ... done

@lonvia
Copy link
Copy Markdown
Member

lonvia commented Apr 13, 2026

Can we go back to the version without a project in the base pyproject.toml?

@Itz-Agasta
Copy link
Copy Markdown
Contributor Author

Itz-Agasta commented Apr 14, 2026

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.

and sorry for the communication delay.. my end sem exams are on-going :(

@lonvia lonvia merged commit 2331bad into osm-search:master Apr 21, 2026
8 checks passed
@lonvia
Copy link
Copy Markdown
Member

lonvia commented Apr 21, 2026

Thanks and sorry for the long wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants