Skip to content

Migrate from pip/setup.py to uv for dependency management#5913

Merged
suhaibmujahid merged 9 commits intomozilla:masterfrom
suhaibmujahid:use-uv
Apr 4, 2026
Merged

Migrate from pip/setup.py to uv for dependency management#5913
suhaibmujahid merged 9 commits intomozilla:masterfrom
suhaibmujahid:use-uv

Conversation

@suhaibmujahid
Copy link
Copy Markdown
Member

Resolves #5022

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the project from pip/setup.py/requirements files to uv + pyproject.toml (Hatchling) to improve onboarding and lock dependency resolution (Resolves #5022).

Changes:

  • Replaces root packaging with pyproject.toml (Hatchling), moving dependencies/extras/scripts and removing setup.py/MANIFEST.in/requirements files.
  • Updates Taskcluster, Dockerfiles, and docs to install/sync dependencies via uv and use uv.lock.
  • Migrates http_service to its own pyproject.toml + uv.lock and adjusts compose/Docker build contexts accordingly.

Reviewed changes

Copilot reviewed 22 out of 26 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test-requirements.txt Removes legacy test requirements file (moved into pyproject.toml dependency groups).
requirements.txt Removes legacy runtime requirements file (moved into pyproject.toml).
setup.py Removes legacy setuptools packaging (replaced by Hatchling in pyproject.toml).
MANIFEST.in Removes legacy manifest handling (replaced by Hatch build config).
pyproject.toml Adds Hatchling project metadata, dependencies, optional deps, dependency groups, and scripts.
README.md Updates setup instructions to uv sync and documents dependency groups/extras + Python version.
scripts/integration_test.sh Switches http_service install step from pip install to uv sync.
infra/spawn_pipeline_requirements.txt Removes legacy spawn pipeline requirements file (moved into dependency group).
infra/dockerfile.base Uses uv for dependency sync/install during image build.
infra/dockerfile.base-nlp Uses uv + --extra nlp to provision NLP base image deps.
infra/dockerfile.spawn_pipeline Uses uv + --only-group spawn-pipeline to provision spawn pipeline deps.
http_service/setup.py Removes legacy setuptools packaging for http_service.
http_service/requirements.txt Removes legacy http_service requirements file (moved into http_service/pyproject.toml).
http_service/pyproject.toml Adds Hatchling-based packaging + deps + local source reference to bugbug.
http_service/MANIFEST.in Removes legacy manifest rule for templates.
http_service/Dockerfile Switches build/install flow from pip to uv, uses http_service lockfile.
http_service/Dockerfile.bg_worker Switches build/install flow from pip to uv, uses http_service lockfile.
http_service/docker-compose.yml Updates build context/dockerfile paths to reflect root context + new Dockerfile locations.
extra-nlp-requirements.txt Removes legacy NLP extra requirements file (moved into optional deps).
docker-compose.yml Updates service build contexts/dockerfiles to root context (needed for bind mounts + lockfiles).
.taskcluster.yml Migrates CI jobs from pip installs to uv sync/uv run; removes MCP test task.
.pre-commit-config.yaml Removes requirements-txt-fixer hook (requirements files removed).
.github/dependabot.yml Moves root Python updates from pip to uv and expands directories.
Comments suppressed due to low confidence (1)

.taskcluster.yml:262

  • The release dependency list no longer includes the MCP tests task, even though services/mcp/ has its own test suite. This means MCP tests can regress without being caught by the required CI gate. Consider re-adding the MCP test task (or an equivalent check) to the release dependency chain.
              - dependencies:
                  - { $eval: as_slugid("lint_task") }
                  - { $eval: as_slugid("tests_task") }
                  - { $eval: as_slugid("http_tests_task") }
                  - { $eval: as_slugid("frontend_build") }
                  - { $eval: as_slugid("packaging_test_task") }
                  - { $eval: as_slugid("version_check_task") }
                  - { $eval: as_slugid("integration_test") }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@suhaibmujahid suhaibmujahid force-pushed the use-uv branch 2 times, most recently from 5b457c3 to d5737cf Compare April 3, 2026 02:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 27 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

.taskcluster.yml:261

  • The mcp_tests_task was removed from the Taskcluster config, but services/mcp/ (including tests/) still exists in the repo. This looks unrelated to the stated goal of migrating to uv and reduces CI coverage for the MCP service. Please either restore an equivalent MCP test task using uv or document/justify why MCP tests are no longer required.
        - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
          then:
            $mergeDeep:
              - { $eval: default_task_definition }
              - dependencies:
                  - { $eval: as_slugid("lint_task") }
                  - { $eval: as_slugid("tests_task") }
                  - { $eval: as_slugid("http_tests_task") }
                  - { $eval: as_slugid("frontend_build") }
                  - { $eval: as_slugid("packaging_test_task") }
                  - { $eval: as_slugid("version_check_task") }
                  - { $eval: as_slugid("integration_test") }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@suhaibmujahid suhaibmujahid enabled auto-merge (rebase) April 4, 2026 02:03
Comment on lines +22 to +24
- "/"
- "/services/mcp"
- "/services/reviewhelper-api"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a way to just find all files in any directory, so we don't have to specify and remember to add/remove them when necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could use /services/* 1. I will do that.

Footnotes

  1. Dependabot options reference

Copy link
Copy Markdown
Member Author

@suhaibmujahid suhaibmujahid Apr 4, 2026

Choose a reason for hiding this comment

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

Done in 779fe79

import shelve
import shutil
import struct
import tomllib
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why was the change in this file necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because the project's requires-python changed from >=3.10 (in the old setup.py) to >=3.12 (in the new pyproject.toml).

tomllib was added to the stdlib in Python 3.11. With the old >=3.10 constraint, ruff/isort treated it as a third-party import (since it was not exist in 3.10). With >=3.12, ruff knows it's always stdlib, so it expects it sorted with the other stdlib imports.

"flask-cors==6.0.2",
"gunicorn==25.1.0",
"kombu==5.6.2",
"marshmallow>=3.18.0",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was ==4.2.2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We had a non-obvious conflict — pip was only warning about it rather than failing. The chain was: langchain-community==0.4.1dataclasses-json==0.6.7marshmallow>=3.18.0,<4.0.0. uv's strict resolver caught this transitive conflict that pip silently ignored.

I'll file a follow-up issue to remove langchain-community, as I don't think it's actually needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Filed #5914

.taskcluster.yml Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of installing uv in tasks, we could use an image with uv here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was hesitance to do that, but it is a good idea. I will do that.

Copy link
Copy Markdown
Member Author

@suhaibmujahid suhaibmujahid Apr 4, 2026

Choose a reason for hiding this comment

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

Done in f1063e9

marco-c
marco-c previously approved these changes Apr 4, 2026
@suhaibmujahid suhaibmujahid disabled auto-merge April 4, 2026 15:58
@suhaibmujahid suhaibmujahid merged commit ea5ae2e into mozilla:master Apr 4, 2026
6 checks passed
@suhaibmujahid suhaibmujahid deleted the use-uv branch April 4, 2026 15:58
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.

Adopt uv as a Python package and project manager

3 participants