Skip to content

Switch to dynamic uv-compiled requirements management#120

Open
5hojib wants to merge 1 commit intobetafrom
uv-requirements-dynamic-2708042962590808586
Open

Switch to dynamic uv-compiled requirements management#120
5hojib wants to merge 1 commit intobetafrom
uv-requirements-dynamic-2708042962590808586

Conversation

@5hojib
Copy link
Member

@5hojib 5hojib commented Mar 10, 2026

This change transitions the project from static dependencies in pyproject.toml to a more robust uv-based workflow using requirements.in files.

Key changes:

  1. New Requirements Architecture: Created requirements.in, requirements-dev.in, and requirements-docs.in without version constraints to allow uv to resolve the best versions.
  2. Dynamic Metadata: Updated pyproject.toml to use the hatch-requirements-txt build hook, marking dependencies and optional-dependencies as dynamic.
  3. CI/CD Integration: Modified the Format and test GitHub workflow to re-compile the .in files into .txt files using uv pip compile whenever it runs, ensuring the pinned requirements stay up to date.
  4. Compatibility Maintenance: Ensured the project still supports Python 3.10+ by handling a conflict between sphinx 9.x (which requires 3.12+) and the project's base requirement by constraining sphinx < 8.0.0 in the docs extra.
  5. Clean Lockfile: Re-synchronized uv.lock with the new dynamic configuration.

PR created automatically by Jules for task 2708042962590808586 started by @5hojib

Summary by Sourcery

Switch project dependency management to dynamic, uv-compiled requirements files and integrate this workflow into CI.

New Features:

  • Introduce requirements.in, requirements-dev.in, and requirements-docs.in as the source of truth for runtime, development, and documentation dependencies.

Enhancements:

  • Make project dependencies and optional dependencies dynamic in pyproject.toml using the hatch-requirements-txt metadata hook driven by compiled requirements.txt files.
  • Extend the build system to depend on hatch-requirements-txt for generating metadata from pinned requirement files.
  • Add a CI step to compile .in requirement files into pinned .txt files with uv and commit them as part of the workflow.

Build:

  • Update the Hatch build configuration to use the requirements_txt metadata hook for core and optional dependency groups.

CI:

  • Modify the format_and_test GitHub Actions workflow to compile and stage requirements.txt, requirements-dev.txt, and requirements-docs.txt on each run.

Chores:

  • Refresh uv.lock and add generated requirements.txt-style lock files aligned with the new dependency management flow.

- Added `requirements.in`, `requirements-dev.in`, and `requirements-docs.in` for dependency management.
- Configured `pyproject.toml` to use `hatch-requirements-txt` for dynamic dependencies.
- Updated `.github/workflows/format_and_test.yml` to automatically re-compile requirements during formatting.
- Maintained Python 3.10+ compatibility by pinning `docutils` and constraining `sphinx` in docs requirements.
- Compiled lock-file versions into `.txt` files using `uv pip compile`.
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 10, 2026

Reviewer's Guide

Transitions dependency management from static entries in pyproject.toml to a dynamic, uv-compiled requirements workflow, wiring it into Hatch metadata and CI so pinned requirements are generated from .in files while preserving Python 3.10+ compatibility.

Sequence diagram for CI run with uv compilation and hatch dynamic dependencies

sequenceDiagram
    actor Developer
    participant Repo
    participant GitHubActions
    participant Uv
    participant RequirementsIn
    participant RequirementsTxt
    participant UvLock
    participant Hatchling
    participant HatchReqHook

    Developer->>Repo: Push commits
    Repo-->>GitHubActions: Trigger Format_and_test workflow

    GitHubActions->>Uv: uv pip compile requirements.in
    Uv->>RequirementsIn: Read requirements.in
    Uv->>RequirementsTxt: Write requirements.txt
    Uv->>UvLock: Update lock entries

    GitHubActions->>Uv: uv pip compile requirements-dev.in
    Uv->>RequirementsIn: Read requirements-dev.in
    Uv->>RequirementsTxt: Write requirements-dev.txt
    Uv->>UvLock: Update lock entries

    GitHubActions->>Uv: uv pip compile requirements-docs.in
    Uv->>RequirementsIn: Read requirements-docs.in
    Uv->>RequirementsTxt: Write requirements-docs.txt
    Uv->>UvLock: Update lock entries

    GitHubActions->>GitHubActions: Run tests and formatting
    GitHubActions->>Hatchling: Build package
    Hatchling->>HatchReqHook: Invoke metadata hook
    HatchReqHook->>RequirementsTxt: Read pinned requirements
    HatchReqHook-->>Hatchling: Provide dynamic dependencies
    Hatchling-->>GitHubActions: Complete build with resolved deps
Loading

Flow diagram for dynamic requirements compilation and metadata generation

flowchart TD
    A[Edit requirements.in files
requirements.in
requirements-dev.in
requirements-docs.in] --> B[Commit changes to repository]

    B --> C[GitHub Actions
Format_and_test workflow runs]

    C --> D[Run uv pip compile
for each .in file
with --python-version 3.10]

    D --> E[Generate and update
requirements.txt
requirements-dev.txt
requirements-docs.txt]

    D --> F[Update uv.lock
with resolved versions]

    E --> G[Run tests and formatting
using pinned requirements]

    E --> H[Build package with hatchling]

    H --> I[hatch-requirements-txt hook
reads .txt files]

    I --> J[Populate dynamic
project dependencies and
optional-dependencies in pyproject.toml]

    J --> K[Publish or distribute
built package]
Loading

File-Level Changes

Change Details Files
Make project dependencies and extras dynamically sourced from uv-compiled requirements files via hatch-requirements-txt.
  • Mark project dependencies and optional-dependencies as dynamic in project metadata
  • Remove inline dependencies and optional-dependencies tables from project configuration
  • Configure hatch-requirements-txt metadata hook to pull core and extra requirements from generated requirements.txt files
  • Extend build-system requirements to include hatch-requirements-txt so builds can resolve metadata from text files
pyproject.toml
Integrate requirements compilation into the CI workflow so .txt lock-style files are regenerated from .in inputs on each run.
  • Add a dedicated step in the format_and_test workflow to run uv pip compile for base, dev, and docs requirement sets
  • Ensure compiled requirements files are added back to the git index to keep them in sync with the source .in files and lockfile
.github/workflows/format_and_test.yml
Introduce uv-driven requirements input and compiled output files, and refresh the uv lockfile to align with dynamic metadata.
  • Add unpinned requirements.in files for base, dev, and docs environments as the single source of truth for dependency sets
  • Add compiled requirements.txt, requirements-dev.txt, and requirements-docs.txt with pinned versions targeting Python 3.10
  • Update uv.lock to reflect the newly resolved dependency graph under the dynamic configuration
requirements.in
requirements-dev.in
requirements-docs.in
requirements.txt
requirements-dev.txt
requirements-docs.txt
uv.lock

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!

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the project's dependency management system by transitioning from static pyproject.toml definitions to a dynamic, uv-based workflow. This change centralizes dependency resolution, improves maintainability, and ensures consistent environments across development and deployment by leveraging requirements.in files and automated compilation.

Highlights

  • New Requirements Architecture: Created requirements.in, requirements-dev.in, and requirements-docs.in files without version constraints, allowing uv to resolve optimal versions.
  • Dynamic Metadata: Updated pyproject.toml to utilize the hatch-requirements-txt build hook, declaring dependencies and optional-dependencies as dynamic.
  • CI/CD Integration: Modified the Format and test GitHub workflow to automatically re-compile .in files into .txt files using uv pip compile, ensuring up-to-date pinned requirements.
  • Compatibility Maintenance: Addressed a compatibility conflict between sphinx 9.x (requiring Python 3.12+) and the project's Python 3.10+ base by constraining sphinx < 8.0.0 in the documentation extra.
  • Clean Lockfile: Re-synchronized uv.lock to align with the new dynamic dependency configuration.
Changelog
  • pyproject.toml
    • Removed static dependencies and optional-dependencies definitions.
    • Added hatch-requirements-txt build hook configuration.
    • Marked dependencies and optional-dependencies as dynamic.
    • Included hatch-requirements-txt in build-system.requires.
  • requirements-dev.in
    • Created requirements-dev.in for development dependencies.
  • requirements-dev.txt
    • Created requirements-dev.txt with compiled development dependencies.
  • requirements-docs.in
    • Created requirements-docs.in for documentation dependencies.
  • requirements-docs.txt
    • Created requirements-docs.txt with compiled documentation dependencies.
  • requirements.in
    • Created requirements.in for core project dependencies.
  • requirements.txt
    • Created requirements.txt with compiled core project dependencies.
  • uv.lock
    • Removed resolution-markers section.
    • Updated pinned versions and hashes for numerous packages including alabaster, cffi, cryptography, python-discovery, sphinx, and tornado.
    • Removed the roman-numerals package.
    • Refactored package.optional-dependencies and package.metadata.requires-dist to list all resolved dependencies with exact versions.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/format_and_test.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@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 - I've left some high level feedback:

  • The workflow step that runs git add requirements*.txt inside CI will create dirty commits that don’t exist locally; consider dropping the git add and treating the compiled files as build artifacts rather than something modified during CI runs.
  • With dependencies and optional-dependencies now fully dynamic, make sure the corresponding requirements*.in files actually capture the previous runtime/dev/docs dependencies (and any version bounds that matter), otherwise published wheels may end up missing required packages.
  • Since the project supports Python 3.10+, it’s safer to pass an explicit --python-version 3.10 (or similar minimum) to uv pip compile in the workflow so the pinned requirements remain compatible with the lowest supported Python version rather than the CI runner’s current version.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The workflow step that runs `git add requirements*.txt` inside CI will create dirty commits that don’t exist locally; consider dropping the `git add` and treating the compiled files as build artifacts rather than something modified during CI runs.
- With `dependencies` and `optional-dependencies` now fully dynamic, make sure the corresponding `requirements*.in` files actually capture the previous runtime/dev/docs dependencies (and any version bounds that matter), otherwise published wheels may end up missing required packages.
- Since the project supports Python 3.10+, it’s safer to pass an explicit `--python-version 3.10` (or similar minimum) to `uv pip compile` in the workflow so the pinned requirements remain compatible with the lowest supported Python version rather than the CI runner’s current version.

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions the project's dependency management from static definitions in pyproject.toml to a dynamic, uv-based workflow using requirements.in files. This is a solid improvement for maintainability and reproducibility. The changes correctly update pyproject.toml to use hatch-requirements-txt, introduce requirements.in files for different dependency groups, and update the uv.lock file. I have one suggestion to add a comment explaining a specific version pin for docutils to aid future maintenance.

pytest-asyncio
pytest-cov
twine
docutils==0.21.2
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better maintainability, it would be helpful to add a comment explaining why docutils is pinned to this specific version. This will provide context for future developers who might need to update dependencies.

# Pinned to resolve a dependency conflict
docutils==0.21.2

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.

1 participant