Skip to content

feat(ci): use uv for Python dependency management#1660

Open
yuzhichang wants to merge 2 commits intogeneralaction:mainfrom
yuzhichang:emdash/using-uv-59c
Open

feat(ci): use uv for Python dependency management#1660
yuzhichang wants to merge 2 commits intogeneralaction:mainfrom
yuzhichang:emdash/using-uv-59c

Conversation

@yuzhichang
Copy link
Copy Markdown

@yuzhichang yuzhichang commented Apr 4, 2026

Summary

  • Use uv (astral.sh/setup-uv@v2) instead of actions/setup-python for managing Python build dependencies in CI
  • Add .python-version (Python 3.12) for consistent Python version management
  • Add pyproject.toml for build dependencies (setuptools, wheel) using the standard format
  • Update all 4 CI jobs in release.yml to use uv
  • Add Python/uv setup instructions to CONTRIBUTING.md

Benefits

  • Single source of truth for Python version (.python-version)
  • Eliminates manual npm_config_python workarounds
  • CI becomes faster (uv is 10-100x faster than pip)
  • New contributors get consistent Python setup experience

Test plan

  • Local build with uv Python 3.12 succeeds
  • Native modules rebuild successfully (electron-rebuild)
  • AppImage packaging succeeds

Closes #149

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated contributing guide to require Python 3.12+ and add uv-based setup instructions and example commands.
  • Chores

    • CI workflows now use a shared uv-based Python setup step instead of inline installer steps.
    • Added repository Python version specification (3.12).
    • Added project build-system configuration declaring Python build dependencies.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

@yuzhichang is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

Replaced direct Python installation steps in CI with a new composite action .github/actions/setup-uv-python that installs uv, uses uv to install/locate a Python interpreter (driven by .python-version / pyproject.toml), writes the interpreter path to the environment, and installs Python build deps via uv pip install .. Added .python-version, pyproject.toml, and CONTRIBUTING.md instructions for uv usage.

Changes

Cohort / File(s) Summary
CI / Workflow
.github/workflows/release.yml
Replaced explicit Python setup steps (actions/setup-python + pip/setuptools/wheel installs) with a single composite action ./.github/actions/setup-uv-python that installs uv, runs uv python install and exports the interpreter, and relies on env.python (npm_config_python) for downstream steps.
Composite Action
.github/actions/setup-uv-python/action.yml
New composite action that: installs uv (astral-sh/setup-uv@v8.0.0), runs uv python install and writes python=$(uv python find) to GITHUB_ENV, then runs uv pip install . to install build deps.
Python Version & Build Metadata
.python-version, pyproject.toml
Added .python-version with 3.12. New pyproject.toml declaring emdash-build-deps, requires-python = ">=3.12", runtime/build deps setuptools>=67.0, wheel, and [build-system] using setuptools.build_meta.
Documentation
CONTRIBUTING.md
Added Python 3.12+ prerequisite and a "Python Setup" subsection with cross-platform uv installation commands and example uv pip install . usage for provisioning Python build requirements.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped into CI at the break of day,

uv in my paws to clear the way.
Python found, wheels spin with glee,
Builds hum softly — smooth as can be.
A little hop for every dev and me.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adopting uv for Python dependency management in CI workflows.
Linked Issues check ✅ Passed The PR implements all primary objectives from issue #149: adopts uv for Python management, adds .python-version with Python 3.12, creates pyproject.toml with build dependencies, updates release.yml CI jobs, and documents setup in CONTRIBUTING.md.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #149 objectives; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a89f67 and 8f40e94.

📒 Files selected for processing (4)
  • .github/workflows/release.yml
  • .python-version
  • CONTRIBUTING.md
  • pyproject.toml

CONTRIBUTING.md Outdated
Comment on lines +26 to +27
# Python dependencies are installed automatically via 'pnpm install'
# or manually: uv pip install .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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.cjs

Repository: 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.

Suggested change
# 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.

@yuzhichang yuzhichang force-pushed the emdash/using-uv-59c branch from 8f40e94 to 56b3783 Compare April 4, 2026 14:50
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>
@yuzhichang yuzhichang force-pushed the emdash/using-uv-59c branch from 56b3783 to a76574d Compare April 4, 2026 14:52
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>
@yuzhichang
Copy link
Copy Markdown
Author

@coderabbitai Thanks for the review! Addressed all comments:

  1. Python version: Updated to 3.12+ in CONTRIBUTING.md
  2. Python deps: Clarified that uv pip install . is needed manually
  3. Reusable action: Extracted the 3-step uv/Python setup into .github/actions/setup-uv-python/action.yml - all 4 jobs now use it

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Tip

For best results, initiate chat on the files or code changes.

@yuzhichang: Thanks for the updates! All three changes look great:

  1. Python version — Aligning CONTRIBUTING.md to 3.12+ matches the .python-version file and pyproject.toml constraint, giving contributors a single consistent target.
  2. Python deps clarification — Making the manual uv pip install . step explicit removes ambiguity for contributors setting up outside of pnpm.
  3. Reusable action — Extracting the setup into .github/actions/setup-uv-python/action.yml is a clean DRY improvement; any future changes to the uv/Python setup only need to happen in one place.

Resolving all review comments now.

[resolve]

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
.github/actions/setup-uv-python/action.yml (2)

12-16: Consider handling potential failures and Windows path format.

  1. If .python-version is missing or specifies an unavailable version, uv python install will fail without a clear error message in the workflow logs.
  2. On Windows runners, uv python find may 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 python to GITHUB_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

📥 Commits

Reviewing files that changed from the base of the PR and between a76574d and 425ae19.

📒 Files selected for processing (3)
  • .github/actions/setup-uv-python/action.yml
  • .github/workflows/release.yml
  • CONTRIBUTING.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

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.

Consider using uv for Python dependency management

1 participant