feat(ci): use uv for Python dependency management#1660
feat(ci): use uv for Python dependency management#1660yuzhichang wants to merge 2 commits intogeneralaction:mainfrom
Conversation
|
@yuzhichang is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughReplaced direct Python installation steps in CI with a new composite action Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions Runner
participant SetupAction as .github/actions/setup-uv-python
participant Astral as astral-sh/setup-uv Action
participant UV as uv CLI
participant Python as Python Interpreter
participant PNPM as pnpm / Node build
GH->>SetupAction: uses composite action
SetupAction->>Astral: uses `astral-sh/setup-uv@v8.0.0` to install uv
Astral-->>SetupAction: uv available
SetupAction->>UV: run `uv python install`
UV-->>Python: install/activate requested Python (from .python-version / pyproject)
Python-->>SetupAction: provide interpreter path (written to GITHUB_ENV)
SetupAction->>UV: run `uv pip install .` (install setuptools/wheel)
GH->>PNPM: run `pnpm install` (reads npm_config_python -> env.python)
PNPM-->>Python: node-gyp / native build use configured Python
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/release.yml (1)
52-64: Consider centralizing the repeated uv/Python bootstrap steps.The same 3-step sequence is duplicated in four jobs. A reusable workflow or composite action would reduce drift risk and simplify future updates.
Also applies to: 198-210, 314-328, 492-504
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 52 - 64, Extract the repeated three-step sequence ("Install uv", "Set up Python", "Install Python build deps") into a single reusable unit and replace the duplicated blocks with calls to that unit: create either a reusable workflow (in .github/workflows/) or a composite action (in .github/actions/) that runs the astral-sh/setup-uv step, the uv python install + echo to GITHUB_ENV step, and the uv pip install . step, then update each job to use the new reusable workflow/action via uses: to centralize bootstrapping and remove the four duplicated blocks referenced in the diff.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yml:
- Around line 57-64: The windows-beta-build workflow currently hardcodes Python
3.11 via setup-python@v5; update that workflow to use the same setup-uv approach
as release.yml by replacing the setup-python@v5 step with setup-uv and running
"uv python install" (and echoing the python path into GITHUB_ENV using "echo
\"python=$(uv python find)\" >> $GITHUB_ENV"), and replace any subsequent
pip/install steps that invoke the venv with "uv pip install ." so the workflow
respects the .python-version (3.12) and matches pyproject.toml's
requires-python.
In `@CONTRIBUTING.md`:
- Line 10: Update the Python minimum version string in CONTRIBUTING.md (the line
currently saying "Python 3.11+") to "Python 3.12+" so it matches the project's
declared requirement in .python-version and pyproject.toml; keep the rest of the
line (e.g., the uv reference) unchanged.
- Around line 26-27: Update CONTRIBUTING.md to remove the incorrect claim that
Python dependencies are installed automatically via "pnpm install" and replace
it with an accurate note that the package's postinstall script
(scripts/postinstall.cjs) only runs electron-rebuild and does not install Python
packages; explicitly document the correct installation method for Python deps
(e.g., run pip/uv manually like "python -m pip install ." or provide the exact
manual commands used in the repo) and optionally mention there is currently no
automated step for Python dependency installation.
---
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 52-64: Extract the repeated three-step sequence ("Install uv",
"Set up Python", "Install Python build deps") into a single reusable unit and
replace the duplicated blocks with calls to that unit: create either a reusable
workflow (in .github/workflows/) or a composite action (in .github/actions/)
that runs the astral-sh/setup-uv step, the uv python install + echo to
GITHUB_ENV step, and the uv pip install . step, then update each job to use the
new reusable workflow/action via uses: to centralize bootstrapping and remove
the four duplicated blocks referenced in the diff.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cf4078b7-468f-42fe-895c-c26e43c0125d
📒 Files selected for processing (4)
.github/workflows/release.yml.python-versionCONTRIBUTING.mdpyproject.toml
CONTRIBUTING.md
Outdated
| # Python dependencies are installed automatically via 'pnpm install' | ||
| # or manually: uv pip install . |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "postinstall hook:"
rg -n '"postinstall"' package.json
echo
echo "python/uv references in postinstall script:"
rg -n 'uv|pip|python' scripts/postinstall.cjs || true
echo
echo "electron-rebuild invocation in postinstall script:"
rg -n 'electron-rebuild|spawnSync' scripts/postinstall.cjsRepository: generalaction/emdash
Length of output: 619
Update CONTRIBUTING.md documentation: Python dependencies are not auto-installed via pnpm install
Line 26 incorrectly states Python dependencies install automatically. The postinstall script (scripts/postinstall.cjs) only runs electron-rebuild and contains no Python or uv/pip commands. Update the docs to clarify the actual installation method (manual or automated).
Suggested fix (assuming manual-only)
-# Python dependencies are installed automatically via 'pnpm install'
-# or manually: uv pip install .
+# Install Python build dependencies manually:
+uv pip install .
+# Then install Node dependencies:
+pnpm install📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Python dependencies are installed automatically via 'pnpm install' | |
| # or manually: uv pip install . | |
| # Install Python build dependencies manually: | |
| uv pip install . | |
| # Then install Node dependencies: | |
| pnpm install |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@CONTRIBUTING.md` around lines 26 - 27, Update CONTRIBUTING.md to remove the
incorrect claim that Python dependencies are installed automatically via "pnpm
install" and replace it with an accurate note that the package's postinstall
script (scripts/postinstall.cjs) only runs electron-rebuild and does not install
Python packages; explicitly document the correct installation method for Python
deps (e.g., run pip/uv manually like "python -m pip install ." or provide the
exact manual commands used in the repo) and optionally mention there is
currently no automated step for Python dependency installation.
8f40e94 to
56b3783
Compare
Use uv (astral.sh/setup-uv@v2) instead of actions/setup-python for managing Python build dependencies in CI. This simplifies Python version management and speeds up CI builds. Changes: - Add .python-version (Python 3.12) - Add pyproject.toml for build dependencies (setuptools, wheel) - Update release.yml: replace setup-python with setup-uv across all 4 jobs - Update CONTRIBUTING.md with Python/uv setup instructions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56b3783 to
a76574d
Compare
Address CodeRabbit review comments: - Update Python version in CONTRIBUTING.md from 3.11+ to 3.12+ - Fix incorrect claim about pnpm install handling Python deps - Extract duplicated uv/Python bootstrap steps into .github/actions/setup-uv-python Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@coderabbitai Thanks for the review! Addressed all comments:
|
|
Tip For best results, initiate chat on the files or code changes.
Resolving all review comments now. [resolve] |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/actions/setup-uv-python/action.yml (2)
12-16: Consider handling potential failures and Windows path format.
- If
.python-versionis missing or specifies an unavailable version,uv python installwill fail without a clear error message in the workflow logs.- On Windows runners,
uv python findmay return a Windows-style path (backslashes), which could cause issues if downstream steps expect Unix-style paths.Consider adding error handling or validation:
💡 Optional: Add validation and explicit version logging
- name: Set up Python shell: bash run: | uv python install - echo "python=$(uv python find)" >> $GITHUB_ENV + python_path="$(uv python find)" + echo "Found Python at: $python_path" + "$python_path" --version + echo "python=$python_path" >> $GITHUB_ENV🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/actions/setup-uv-python/action.yml around lines 12 - 16, Wrap the "uv python install" / "uv python find" steps with explicit error handling and normalization: check for the presence of .python-version (or capture the version output) before running "uv python install", fail fast with a clear error message if install exits non‑zero, and when capturing the path from "uv python find" normalize Windows backslashes to POSIX slashes before appending to GITHUB_ENV (or validate the path exists), ensuring any failure logs the failing command and version variable for easier debugging.
1-20: Consider adding outputs for better reusability.The action exports
pythontoGITHUB_ENV, making it available to subsequent steps in the same job. However, declaring explicit outputs would improve reusability and make the action's contract clearer:💡 Optional: Declare outputs for improved action interface
name: "Set up uv and Python" description: "Installs uv, sets up Python via .python-version, and installs build deps from pyproject.toml" +outputs: + python-path: + description: "Path to the installed Python interpreter" + value: ${{ steps.setup-python.outputs.python-path }} + runs: using: composite steps: - name: Install uv uses: astral-sh/setup-uv@v8.0.0 with: version: "0.11.3" - name: Set up Python + id: setup-python shell: bash run: | uv python install - echo "python=$(uv python find)" >> $GITHUB_ENV + python_path="$(uv python find)" + echo "python=$python_path" >> $GITHUB_ENV + echo "python-path=$python_path" >> $GITHUB_OUTPUT - name: Install Python build deps shell: bash run: uv pip install .🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/actions/setup-uv-python/action.yml around lines 1 - 20, Declare an outputs section in the composite action and wire it to a step output so downstream workflows can consume the installed Python path; add an outputs: python: entry at the top-level of action.yml and update the "Set up Python" step to have an id (e.g., id: set_python) and emit the value to $GITHUB_OUTPUT (use echo "python=$(uv python find)" >> $GITHUB_OUTPUT) instead of only writing to GITHUB_ENV, then map the composite output to that step with python: ${{ steps.set_python.outputs.python }} so consumers can reference the action output.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/actions/setup-uv-python/action.yml:
- Around line 12-16: Wrap the "uv python install" / "uv python find" steps with
explicit error handling and normalization: check for the presence of
.python-version (or capture the version output) before running "uv python
install", fail fast with a clear error message if install exits non‑zero, and
when capturing the path from "uv python find" normalize Windows backslashes to
POSIX slashes before appending to GITHUB_ENV (or validate the path exists),
ensuring any failure logs the failing command and version variable for easier
debugging.
- Around line 1-20: Declare an outputs section in the composite action and wire
it to a step output so downstream workflows can consume the installed Python
path; add an outputs: python: entry at the top-level of action.yml and update
the "Set up Python" step to have an id (e.g., id: set_python) and emit the value
to $GITHUB_OUTPUT (use echo "python=$(uv python find)" >> $GITHUB_OUTPUT)
instead of only writing to GITHUB_ENV, then map the composite output to that
step with python: ${{ steps.set_python.outputs.python }} so consumers can
reference the action output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3908a148-8acf-49c9-9677-46033c95af2a
📒 Files selected for processing (3)
.github/actions/setup-uv-python/action.yml.github/workflows/release.ymlCONTRIBUTING.md
✅ Files skipped from review due to trivial changes (1)
- CONTRIBUTING.md
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/release.yml
Summary
uv(astral.sh/setup-uv@v2) instead ofactions/setup-pythonfor managing Python build dependencies in CI.python-version(Python 3.12) for consistent Python version managementpyproject.tomlfor build dependencies (setuptools, wheel) using the standard formatrelease.ymlto use uvBenefits
npm_config_pythonworkaroundsTest plan
Closes #149
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Chores