Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt uv as Python package manager #311

Merged
merged 4 commits into from
Mar 25, 2025

Conversation

hongquan
Copy link
Member

@hongquan hongquan commented Mar 20, 2025

Fixes #301

How has this been tested?

  • Build Docker image from the new Dockerfile (which is updated to use uv).
  • Test to make sure the app inside Docker image still works.
  • Build doc.

image

Checklist

  • I have added tests to cover my changes.

Copy link

sourcery-ai bot commented Mar 20, 2025

Reviewer's Guide by Sourcery

This pull request migrates the project from pip to uv for Python package management. It includes changes to pyproject.toml to define dependency groups, updates to Dockerfile and GitHub Actions workflows to use uv commands, and the addition of a uv.lock file. The change also refactors the dependency management in pyproject.toml and updates linting configurations.

Updated class diagram for pyproject.toml dependencies

classDiagram
    class pyproject.toml {
        -dependencies: list
        -optional-dependencies: dict
        +project.urls: dict
        +dependency-groups: dict
        +tool.uv: dict
    }
    note for pyproject.toml "Refactored dependencies and added uv configuration"
Loading

File-Level Changes

Change Details Files
Replaced pip with uv as the Python package manager.
  • Replaced pip commands with uv commands in Dockerfile and GitHub Actions workflows.
  • Added uv.lock file to lock dependencies.
  • Configured uv in pyproject.toml to manage default dependency groups.
  • Installed uv using astral-sh/setup-uv@v5 GitHub Action.
  • Removed explicit pip install commands for dependencies in favor of uv sync.
pyproject.toml
Dockerfile
.github/workflows/style.yml
.github/workflows/tests.yml
.github/workflows/build.yml
.github/workflows/docs.yml
.github/workflows/strings.yml
.github/workflows/gh-pages-deploy.yml
uv.lock
Refactored dependency management in pyproject.toml.
  • Reorganized dependencies into [dependency-groups] for lint, test, dev, and doc.
  • Added gunicorn as a direct dependency.
  • Removed black, build, check-manifest, coverage, djhtml, Faker, flake8, flake8-bugbear, freezegun, isort, jsonschema, lxml, pytest, pytest-cov, pytest-django, pytest-mock, pytest-sugar, pytest-xdist, pywatchman, responses, and urllib3 from the dev optional dependency group and moved them to dependency groups.
  • Added sphinx-autobuild, sphinx, sphinx-autodoc-typehints, sphinx-copybutton, sphinxcontrib-django, sphinxcontrib-httpdomain, and sphinxcontrib-spelling to the doc dependency group.
pyproject.toml
Updated linting configuration.
  • Replaced isort and flake8 commands with uvx commands in .github/workflows/style.yml.
  • Replaced djhtml command with uv run djhtml in .github/workflows/style.yml.
.github/workflows/style.yml
Removed unused files.
  • Removed MANIFEST.in and doc/developer/setup.rst.
MANIFEST.in
doc/developer/setup.rst

Assessment against linked issues

Issue Objective Addressed Explanation
#301 Migrate the project to use uv as the Python package manager.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hongquan - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding uv generate-lockfile to your CI to keep the lockfile up to date.
  • It looks like you've removed the tool.setuptools.dynamic section, but it's still needed to dynamically set the version.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hongquan
Copy link
Member Author

@sourcery-ai:

  • The generate-lockfile subcommand doesn't exist with current uv version (v.0.5.11). You may mistake with another tool.
  • The tool.setuptools.dynamic is still there. You may not recognize the TOML syntax.

@hongquan
Copy link
Member Author

  • The failing CI jobs are not due to missing packages, meaning uv is working. Those failed because of broken docs or outdated test cases.

@hongquan hongquan requested a review from norbusan March 20, 2025 12:43
Copy link
Member

@norbusan norbusan left a comment

Choose a reason for hiding this comment

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

Please remove unrelated changes, it is puzzling, at makes it MUCH harder to revert in case we need to revert it.

Copy link
Member

@norbusan norbusan left a comment

Choose a reason for hiding this comment

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

LGTM, although there are still some whitespace related changes in pyproject.toml and some others.
But that is fine somehow.

@hongquan hongquan merged commit b61a3e2 into fossasia:development Mar 25, 2025
4 of 7 checks passed
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.

Use uv as Python package manager
2 participants