Skip to content

build: switch from pip to uv for dependency management#416

Merged
jmeridth merged 4 commits intomainfrom
jm_switch_to_uv
Mar 8, 2026
Merged

build: switch from pip to uv for dependency management#416
jmeridth merged 4 commits intomainfrom
jm_switch_to_uv

Conversation

@jmeridth
Copy link
Collaborator

@jmeridth jmeridth commented Mar 8, 2026

Pull Request

Proposed Changes

What

Replace pip-based dependency management with uv across the project, consolidating requirements.txt and requirements-test.txt into pyproject.toml with a generated uv.lock. Add a workflow to keep uv.lock in sync on Dependabot PRs.

Why

uv provides faster installs, deterministic lockfile resolution, and a simpler single-tool workflow for dependency and virtualenv management.

Notes

  • Dockerfile now copies uv binary from ghcr.io/astral-sh/uv:latest and uses uv sync --frozen --no-dev instead of pip install
  • CI workflows use astral-sh/setup-uv with caching enabled
  • test_contributors.py reformatted by black (with-statement style change)
  • Dependabot will update pyproject.toml but does not natively understand uv.lock, so update-uv-lock.yml auto-commits the regenerated lockfile back to Dependabot PR branches
  • If branch protection requires signed commits, the update-uv-lock workflow may need a GitHub App token instead of GITHUB_TOKEN
  • Update CI workflow matrix to include Python 3.13 and 3.14
  • Added linter config for codespell to ignore astroid (uv org). It thinks it should be asteroid. 😄

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing

@jmeridth jmeridth self-assigned this Mar 8, 2026
@jmeridth jmeridth requested a review from zkoppert as a code owner March 8, 2026 03:28
Copilot AI review requested due to automatic review settings March 8, 2026 03:28
## What

Replace pip-based dependency management with uv across the project,
consolidating requirements.txt and requirements-test.txt into
pyproject.toml with a generated uv.lock. Add a workflow to keep
uv.lock in sync on Dependabot PRs.

## Why

uv provides faster installs, deterministic lockfile resolution, and
a simpler single-tool workflow for dependency and virtualenv management.

## Notes

- Dockerfile now copies uv binary from ghcr.io/astral-sh/uv:latest and
  uses uv sync --frozen --no-dev instead of pip install
- CI workflows use astral-sh/setup-uv with caching enabled
- test_contributors.py reformatted by black (with-statement style change)
- Dependabot will update pyproject.toml but does not natively understand
  uv.lock, so update-uv-lock.yml auto-commits the regenerated lockfile
  back to Dependabot PR branches
- If branch protection requires signed commits, the update-uv-lock
  workflow may need a GitHub App token instead of GITHUB_TOKEN
- Update CI matrix to include python 3.13 and 3.14

Signed-off-by: jmeridth <jmeridth@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the project's dependency management from pip (with requirements.txt and requirements-test.txt) to uv, consolidating dependencies into pyproject.toml with a deterministic uv.lock. It also updates CI workflows, the Dockerfile, the Makefile, and documentation to use uv commands.

Changes:

  • Replaced requirements.txt and requirements-test.txt with pyproject.toml and uv.lock; updated Dockerfile, Makefile, and all CI workflows to use uv sync / uv run instead of pip
  • Added .github/workflows/update-uv-lock.yml to auto-regenerate uv.lock when Dependabot modifies pyproject.toml
  • Reformatted test_contributors.py with-statement blocks using Black's parenthesized context manager style (cosmetic only)

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml New file defining project metadata, runtime dependencies, and dev dependency group
uv.lock Auto-generated lockfile for deterministic dependency resolution
requirements.txt Deleted — replaced by pyproject.toml
requirements-test.txt Deleted — replaced by pyproject.toml dev dependencies
Dockerfile Uses COPY --from=ghcr.io/astral-sh/uv:latest and uv sync --frozen --no-dev; changes ENTRYPOINT to uv run
Makefile Prefixes all Python tool commands with uv run
README.md Updates local usage instructions to reference uv
.github/workflows/python-ci.yml Replaces setup-python + pip install with setup-uv + uv sync
.github/workflows/copilot-setup-steps.yml Same uv migration as python-ci.yml
.github/workflows/update-uv-lock.yml New workflow to keep uv.lock in sync on Dependabot PRs
test_contributors.py Black reformatting of with blocks (no functional change)

## What

Pin the uv Docker image to a versioned digest, restore unbuffered
Python output in the container, and update the super-linter workflow
to use uv instead of the deleted requirements files.

## Why

The review identified three issues: supply-chain risk from using a
mutable :latest tag, loss of unbuffered stdout/stderr behavior needed
for GitHub Actions log streaming, and the super-linter workflow still
referencing the removed requirements.txt files.

## Notes

- uv image pinned to 0.10.9@sha256:10902f58... — will need Dependabot
  or manual updates to rotate
- PYTHONUNBUFFERED=1 replaces the previous python3 -u entrypoint flag

Signed-off-by: jmeridth <jmeridth@gmail.com>
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python3 -c "import os,sys; sys.exit(0 if os.path.exists('/action/workspace/contributors.py') else 1)"

ENV PYTHONUNBUFFERED=1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is in place of the -u that used to be passed to python3 in the ENTRYPOINT.

contributors_module.markdown, "write_to_markdown"
), patch.object(
contributors_module.json_writer, "write_to_json"
with (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

linting formatting fix, nothing more.

contributors_module.markdown, "write_to_markdown"
), patch.object(
contributors_module.json_writer, "write_to_json"
with (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

linting formatting fix, nothing more.

@@ -0,0 +1,35 @@
---
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this whole workflow is required because dependabot uv management doesn't handle uv.lock files. Renovate does but we'd need to have the app installed into the github-community-projects org. Figured this was easier. If we do head down the Renovate path, I'd like to entertain installing the octo-sts app also. A conversation for later.

jmeridth added 2 commits March 7, 2026 21:47
## What

Fix zizmor bot-conditions audit and codespell false positive on uv.lock.

## Why

The zizmor audit flagged github.actor as spoofable since it refers to the
last actor to modify the PR, not the creator. Codespell flagged "astroid"
(a real Python package) in uv.lock as a misspelling of "asteroid".

## Notes

- Replaced github.actor with github.event.pull_request.user.login which
  refers to the PR creator and cannot be spoofed by later commits
- Added .codespellrc to ignore-words-list for "astroid"

Signed-off-by: jmeridth <jmeridth@gmail.com>
## What

Add .venv to jscpd ignore list in the linter configuration.

## Why

The uv sync step creates a .venv in the workspace during CI. jscpd was
scanning vendored C files inside mypyc and reporting 50.58% duplication
over the 50% threshold, failing the super-linter check.

## Notes

- This only became an issue after switching to uv, which creates .venv
  in the workspace rather than installing into the system Python

Signed-off-by: jmeridth <jmeridth@gmail.com>
Copy link
Collaborator

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

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

🚀

@jmeridth jmeridth merged commit d699725 into main Mar 8, 2026
38 checks passed
@jmeridth jmeridth deleted the jm_switch_to_uv branch March 8, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants