Skip to content

Use uv for dependency handling#817

Merged
yegor256 merged 26 commits into
cqfn:masterfrom
AntonProkopyev:682-support-uv
Jul 9, 2025
Merged

Use uv for dependency handling#817
yegor256 merged 26 commits into
cqfn:masterfrom
AntonProkopyev:682-support-uv

Conversation

@AntonProkopyev

@AntonProkopyev AntonProkopyev commented Jun 8, 2025

Copy link
Copy Markdown
Contributor

Closes #682

Summary by CodeRabbit

  • New Features

    • Centralized environment and command execution using the uv tool across development, testing, and release processes.
  • Improvements

    • Updated Makefile and workflows to utilize uv for dependency management, testing, linting, and building.
    • Enhanced end-to-end testing script to use uv for virtual environment creation and package installation.
    • Updated documentation to reflect new Python (3.11+) and uv requirements.
    • Explicitly defined dependencies and development tools in project configuration for improved compatibility and clarity.
  • Chores

    • Removed the requirements.txt file, consolidating dependency management.
    • Added uv.lock to REUSE annotations.

@coderabbitai

coderabbitai Bot commented Jun 8, 2025

Copy link
Copy Markdown

Walkthrough

The codebase and CI workflows have been updated to standardize the use of the uv tool for Python dependency management, environment creation, and command execution. This includes changes to the Makefile, GitHub Actions workflows, release scripts, documentation, and the end-to-end test script, all now leveraging uv instead of direct pip or Python invocations.

Changes

Files / Grouped Files Change Summary
.github/workflows/e2e-release.yml, make.yml, pylint.yml, ty.yml GitHub Actions workflows updated to install and use uv for dependency management and command execution.
.rultor.yml Release script updated to use uv for installing and running Python tools, replacing direct pip and Python calls.
Makefile All Python-related commands now routed through uv; targets updated; clean target extended; e2e target modified.
README.md Documentation updated to require Python 3.11+, recommend/use uv, and provide new setup and contribution instructions.
pyproject.toml Explicitly listed dependencies and added [dependency-groups] for dev dependencies; removed dynamic requirements from external files.
test/e2e/test_e2e_release.sh e2e test script now uses uv venv and supports specifying the dist directory; activation logic updated.
REUSE.toml Added uv.lock to REUSE annotations.
requirements.txt Removed entirely, as dependencies are now declared in pyproject.toml.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions
    participant Runner as Workflow Runner
    participant uv as uv Tool
    participant Python as Python Environment

    CI->>Runner: Start workflow job
    Runner->>uv: Install uv via script
    uv->>Runner: uv installed and PATH updated
    Runner->>uv: Create virtual environment / sync dependencies
    uv->>Python: Setup environment, install dependencies
    Runner->>uv: Run commands (test, lint, build, etc.)
    uv->>Python: Execute tasks in managed environment
Loading

Assessment against linked issues

Objective Addressed Explanation
Add uv for safer, more convenient, and faster Python dependency management (#682)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected related to the linked issue #682.

Possibly related PRs

  • Add e2e package tests #825: Introduced the e2e-release workflow and test script, which are now further enhanced and integrated with uv in this PR.

Suggested reviewers

  • ivanovmg

Poem

In the warren of code, a new tool we see,
"uv" hops in, setting dependencies free!
No more pip tangles, no more old woes,
With swift little paws, our project now grows.
From CI to docs, the changes are grand—
A bunny-approved upgrade, just as we planned! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2889096 and d70cc95.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: make
  • GitHub Check: latexmk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AntonProkopyev
AntonProkopyev marked this pull request as ready for review June 9, 2025 08:22
@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@ivanovmg (cc: @yegor256) please take a look here

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (15)
pyproject.toml (1)

49-59: Dev‐dependencies configuration looks solid.
The new [tool.uv] section correctly declares your development tools and minimum versions for pytest, flake8, pylint, etc.

Consider pinning to patch versions (e.g. pytest==6.2.5) or generating a uv.lock to ensure fully reproducible CI builds.

.github/workflows/pylint.yml (1)

22-25: uv installation step is in place.
The curl-and-sh snippet correctly installs uv and updates PATH before running linting tasks.

You might simplify maintenance by invoking a reusable action or composite step for uv installation across all workflows.

.github/workflows/make.yml (1)

26-29: Consistent uv setup in CI.
The new Install uv step mirrors other workflows and ensures make targets leverage uv.

Consider extracting this into a reusable GitHub Action or workflow template to DRY up multiple workflow files.

.github/workflows/e2e-release.yml (3)

6-6: Use unquoted on: key for workflow triggers.
While YAML allows quoted keys, GitHub Actions examples and linters expect on: without quotes for consistency. Consider changing 'on': to on:.


26-30: Add a verification step for uv installation.
After running the install script, include a uv --version check to confirm the CLI is on PATH and the expected version is installed. For example:

- name: Verify uv installation
  run: uv --version

26-28: Pin or validate the uv install script.
Fetching the installer unpinned can introduce breaking changes. Consider pinning to a specific uv release or verifying the script’s checksum to avoid unexpected updates.

README.md (2)

19-23: Include uv installation instructions.
You recommend using uv but don’t show how to install it. Add an install snippet (e.g. curl -LsSf https://astral.sh/uv/install.sh | sh) in the prerequisites or setup section for clarity.


323-326: Unify pip vs pip3 usage.
The README alternates between pip3 and pip. For consistency, standardize on one (e.g., always pip3) across all code blocks.

test/e2e/test_e2e_release.sh (5)

1-3: Use env-based shebang for portability.
Switch to #!/usr/bin/env bash to ensure the script runs correctly across environments where bash may not be in /bin.


5-7: Consolidate error-handling flags.
Combine set -e and set -o pipefail (and consider set -u) into a single set -euo pipefail for stricter script safety.


19-23: Use pushd/popd for directory changes.
Replacing cd "$TEMP_VENV" / cd - with pushd "$TEMP_VENV" / popd can make context switches clearer and avoid side effects.


60-68: DRY exit-code assertions.
The pattern of set +e, capturing $?, then reverting to set -e repeats. Consider a helper function (e.g., assert_exit_code cmd expected) to reduce duplication and improve readability.


91-93: Explicitly assert help command exit code.
After aibolit check --help, you rely on set -e but don’t verify the exit code. Add a check (if [ $? -ne 0 ] …) to ensure the help invocation succeeds as expected.

Makefile (2)

26-29: Unify integration test invocation.
Instead of uv run python -m test.integration…, consider using uv run pytest test/integration for consistency with the test target.


16-18: Validate that uv.lock is up-to-date.
uv sync updates dependencies but doesn’t enforce the lockfile’s state. Consider adding a check or informing maintainers to commit uv.lock when dependencies change.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6b6682 and de405c0.

📒 Files selected for processing (9)
  • .github/workflows/e2e-release.yml (1 hunks)
  • .github/workflows/make.yml (1 hunks)
  • .github/workflows/pylint.yml (1 hunks)
  • .gitignore (1 hunks)
  • Makefile (1 hunks)
  • README.md (2 hunks)
  • pyproject.toml (1 hunks)
  • test/e2e/__init__.py (1 hunks)
  • test/e2e/test_e2e_release.sh (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/e2e/test_e2e_release.sh (1)
aibolit/__main__.py (1)
  • check (710-799)
🔇 Additional comments (3)
test/e2e/__init__.py (1)

1-2: Package marker file is correct.
Adding the SPDX header in __init__.py makes test/e2e a proper Python package and has no side effects.

README.md (1)

13-14: Ensure Python version consistency across docs.
You raised the requirement to Python 3.11+, but verify all CI workflows and examples (e.g., in .github/workflows) reference 3.11+ instead of older versions.

Makefile (1)

10-10: Default all target omits e2e.
The new end-to-end tests (e2e) aren’t part of the all target. Please confirm if this is intentional or if all should run e2e as well.

Comment thread .gitignore Outdated
@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

need to patch a .rultor.yml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.rultor.yml (1)

26-27: Evaluate version‐check commands’ necessity
Running both uv run python --version and uv --version adds noise to the release logs. Consider removing or gating these checks (e.g., only on a debug flag) to reduce log clutter.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de405c0 and bcc0765.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • .rultor.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: latexmk
  • GitHub Check: make
🔇 Additional comments (3)
.rultor.yml (3)

18-18: The export PATH in the merge stage is necessary to expose uv for downstream commands and is correctly scoped within the script block.


22-22: Re-exporting PATH at the start of the release stage is expected (each block runs in a fresh shell). No changes needed.


29-30: Verify build artifacts and token path
Ensure that uv build emits artifacts under dist/ and that the twine_token asset is indeed accessible via ../twine_token. Also consider adding a pre-upload validation step such as uv run twine check dist/* to catch packaging metadata issues early.

Comment thread .rultor.yml Outdated
Comment on lines +12 to +14
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
export PATH="$HOME/.local/bin:$PATH"
uv tool install twine

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Pin and verify the uv installer for reproducibility
The script pulls the latest uv installer unpinned, which can break future CI runs if a breaking change is published. Recommend specifying a fixed release (or channel) and verifying the installer SHA256 before execution.

🤖 Prompt for AI Agents
In .rultor.yml around lines 12 to 15, the script downloads the latest unpinned
uv installer, risking future CI breakage. Modify the curl command to download a
specific pinned version or channel of the uv installer, then verify the
installer's SHA256 checksum before running it. This ensures reproducibility and
prevents unexpected changes from breaking the CI pipeline.

@ivanovmg ivanovmg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@AntonProkopyev thank you for this PR! I believe it is a solid PR targeting transition towards the more modern tools.

I have reservations against including e2e-release workflow in this PR, as it seems to be a complete different feature. It is totally useful, but looks like it deserves another task and PR.

Comment thread Makefile Outdated
Comment thread test/e2e/test_e2e_release.sh Outdated
Comment thread .rultor.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/ty.yml (1)

21-24: Shorten the curl command for YAML compliance and parameterize the version.
Line 23 exceeds the 80-character yamllint limit. Break the installer URL across lines with backslashes or disable the line-length rule on this line (# yamllint disable-line rule:line-length). For easier maintenance, consider defining the uv version as an env variable (e.g. UV_VERSION: 0.7.13) at the top of the workflow instead of hardcoding it.

🧰 Tools
🪛 GitHub Actions: yamllint

[error] 23-23: YAML lint error: line too long (100 > 80 characters) (line-length)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcc0765 and 2293ce4.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/workflows/e2e-release.yml (1 hunks)
  • .github/workflows/make.yml (1 hunks)
  • .github/workflows/pylint.yml (1 hunks)
  • .github/workflows/ty.yml (1 hunks)
  • .rultor.yml (2 hunks)
  • Makefile (2 hunks)
  • README.md (2 hunks)
  • REUSE.toml (1 hunks)
  • pyproject.toml (1 hunks)
  • test/e2e/test_e2e_release.sh (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • REUSE.toml
🚧 Files skipped from review as they are similar to previous changes (8)
  • .github/workflows/e2e-release.yml
  • .github/workflows/pylint.yml
  • .github/workflows/make.yml
  • .rultor.yml
  • pyproject.toml
  • test/e2e/test_e2e_release.sh
  • README.md
  • Makefile
🧰 Additional context used
🪛 GitHub Actions: yamllint
.github/workflows/ty.yml

[warning] 6-6: YAML lint warning: truthy value should be one of [false, true] (truthy)


[error] 23-23: YAML lint error: line too long (100 > 80 characters) (line-length)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: latexmk
  • GitHub Check: make

Comment thread .github/workflows/ty.yml
@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@ivanovmg Thanks for the review! I rebased and updated PR after merging #825. Please take a look.

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
@ivanovmg

Copy link
Copy Markdown
Contributor

@AntonProkopyev are you still working on it?

@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@ivanovmg Yes, I do. Will ship till end of week.

@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@ivanovmg Could you take a look please? Rebased branch. Also fixed dependencies more precisely.

@AntonProkopyev
AntonProkopyev requested a review from ivanovmg July 5, 2025 13:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e56b643 and 27150f1.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/e2e-release.yml (1 hunks)
  • .github/workflows/make.yml (1 hunks)
  • .github/workflows/pylint.yml (1 hunks)
  • .github/workflows/ty.yml (1 hunks)
  • .rultor.yml (2 hunks)
  • Makefile (2 hunks)
  • README.md (2 hunks)
  • REUSE.toml (1 hunks)
  • pyproject.toml (2 hunks)
  • requirements.txt (0 hunks)
  • test/e2e/test_e2e_release.sh (2 hunks)
💤 Files with no reviewable changes (1)
  • requirements.txt
🚧 Files skipped from review as they are similar to previous changes (9)
  • README.md
  • REUSE.toml
  • .github/workflows/e2e-release.yml
  • .github/workflows/pylint.yml
  • .github/workflows/ty.yml
  • .github/workflows/make.yml
  • .rultor.yml
  • test/e2e/test_e2e_release.sh
  • Makefile
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: make
  • GitHub Check: latexmk
🔇 Additional comments (1)
pyproject.toml (1)

26-27: No NumPy<2 constraint in NetworkX 3.2 – compatible with NumPy 2.x

NetworkX 3.2’s PyPI metadata lists only “numpy >=1.22” (no upper bound), so using numpy==2.2.5 satisfies its requirement. No changes needed.

Comment thread pyproject.toml
Comment thread pyproject.toml
@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@yegor256 Could you take a look please?

@yegor256

yegor256 commented Jul 7, 2025

Copy link
Copy Markdown
Member

@ivanovmg are we good here?

Comment thread Makefile Outdated
Co-authored-by: Maxim Ivanov <41443370+ivanovmg@users.noreply.github.com>

@ivanovmg ivanovmg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@AntonProkopyev a minor comment from my side.
Otherwise, looks good!

@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@AntonProkopyev a minor comment from my side.

Otherwise, looks good!

@ivanovmg Thanks for review! Fixed.

@AntonProkopyev

Copy link
Copy Markdown
Contributor Author

@yegor256 All issues were fixed here. Could you merge please?

@ivanovmg ivanovmg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yegor256 looks good to me

@yegor256

yegor256 commented Jul 8, 2025

Copy link
Copy Markdown
Member

@rultor merge

@rultor

rultor commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

@rultor merge

@AntonProkopyev @yegor256 Can't merge this pull requests, because the file .rultor.yml was modified. This is a security threat. Make a separate pull request with the modification of this particular file and ask project architect to merge it manually.

@yegor256
yegor256 merged commit e60f70c into cqfn:master Jul 9, 2025
19 checks passed
@yegor256

yegor256 commented Jul 9, 2025

Copy link
Copy Markdown
Member

@AntonProkopyev thanks!

@yegor256

yegor256 commented Jul 9, 2025

Copy link
Copy Markdown
Member

@AntonProkopyev now codecov.yml is broken, maybe you can fix it too?

@0crat

0crat commented Jul 9, 2025

Copy link
Copy Markdown
Collaborator

@AntonProkopyev Thanks for your contribution! 🚀 You've earned +4 points, which is the minimum reward as per our policy. Here's the breakdown: +16 base points; -8 for exceeding 200 hits-of-code (1770); -16 for surpassing 800 hits-of-code; -16 for no code review; -6 for 31 comments (>8) during review; +34 adjustment to reach the minimum. While the contribution was substantial, remember that our policy emphasizes quality over quantity. For future submissions, consider smaller, more focused changes and engage in code reviews. Your dedication is appreciated, and your running balance is now +108. Keep improving and contributing!

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.

Insecure and inefficient handling of Python dependencies without uv

5 participants