Skip to content

build: lock Python dependencies with uv instead of Rye - #528

Merged
jsenecal merged 1 commit into
mainfrom
build/527-rye-to-uv
Nov 20, 2026
Merged

jsenecal merged 1 commit into
mainfrom
build/527-rye-to-uv

Conversation

@jsenecal

Copy link
Copy Markdown
Collaborator

Closes #527

Problem

Python dependencies on main were locked by Rye, which is no longer developed. rye lock re-resolves unrelated pins (a recent attempt dropped fakeredis[lua]), so new dependencies were added to both requirements*.lock files by hand. renovate.json left Python unmanaged because Renovate cannot regenerate Rye lockfiles, so Python dependencies got no update PRs. Meanwhile CI already installed with uv, and pyproject.toml already had [tool.uv] settings.

Change

  • pyproject.toml: [tool.rye] dev-dependencies → PEP 735 [dependency-groups] dev, same entries. [tool.uv] constraints and overrides unchanged.
  • uv.lock replaces requirements.lock and requirements-dev.lock, and is no longer git-ignored. To keep versions, I locked once with all 104 Rye pins as temporary constraint-dependencies, then removed them and relocked. uv keeps locked versions that still satisfy the requirements.
  • CI (backend, SSH): uv sync --locked --extra ui; cache keyed on uv.lock. --locked fails when pyproject.toml changed without uv lock.
  • Dockerfile, build stage only: uv from ghcr.io/astral-sh/uv:0.13.7 pinned by digest, then uv sync --locked --inexact --no-dev --extra ui --no-install-project into /opt/venv. --inexact keeps the venv's pip for the final stage's editable install, which then removes pip as before. UV_COMPILE_BYTECODE=1 matches pip's default bytecode compilation.
  • Renovate: pep621 manager enabled; non-major Python updates batched into one weekly PR like the UI. Majors still need Dependency Dashboard approval (e.g. paramiko 5, paramiko 5 cannot connect to IOSv and EXOS #418).
  • Labeler, .gitignore, CONTRIBUTING (uv sync --extra ui, uv lock, uv run pytest).

Tests

  • Versions: every package in requirements-dev.lock has the same version in uv.lock; none missing. Only in uv.lock: async-timeout (redis, Python < 3.11.3), mslex and win32-setctime (Windows), uvloop (performance extra), and the project.
  • uv sync --locked --extra ui --python 3.12, then ruff check . (clean) and the backend suite: 4146 passed, 4 skipped.
  • Image: docker build succeeds. importlib.metadata lists the same 67 distributions at the same versions as ghcr.io/hyperglass-community/hyperglass:sha-20c89a92… (diff empty). The final image has no uv and no pip, runs as uid=10001, and hyperglass --help works.
  • renovate-config-validator --strict renovate.json: "Config validated successfully".

Changelog

  • Python dependencies are locked with uv (uv.lock) instead of Rye, and Renovate now updates them.

Notes

  • Expect Renovate's first run with pep621 to open a weekly "Python non-major dependencies" PR, plus Dashboard entries for majors.
  • feat(api): add optional Prometheus metrics #526 adds prometheus-client to the Rye lockfiles by hand. Whichever merges second needs a rebase; after this PR, feat(api): add optional Prometheus metrics #526 runs uv add prometheus-client instead.
  • The CI setup-uv steps use the latest uv; the image pins 0.13.7. A newer uv reads lockfiles written by older ones.

Rye is no longer developed. Its lockfiles had no maintained way to be
updated: `rye lock` re-resolved unrelated pins, new dependencies were
added to both requirements*.lock files by hand, and Renovate could not
regenerate them, so Python dependencies got no update PRs.

- pyproject.toml: [tool.rye] dev-dependencies become the PEP 735 `dev`
  dependency group. The [tool.uv] constraints and overrides stay.
- uv.lock replaces requirements.lock and requirements-dev.lock. It was
  locked with every Rye pin as a temporary constraint, then relocked
  without them, so every previously locked version is kept.
- CI installs with `uv sync --locked --extra ui`, which fails when
  pyproject.toml changes without updating uv.lock.
- The image installs the runtime set from uv.lock with a uv binary
  pinned by digest in the build stage only. The installed packages are
  identical to the current image.
- Renovate manages Python through the pep621 manager, batching
  non-major updates weekly like the UI.
@github-actions github-actions Bot added docs Improve documentation ci Build, test and release pipelines backend Python backend: API, models, state, execution container Docker image and compose labels Nov 20, 2026
@jsenecal
jsenecal requested a review from WilhelmZA November 20, 2026 21:04
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 85.11%. remained the same — build/527-rye-to-uv into main

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at d30acaed.

Every package in the two Rye lock files has the same version in uv.lock, so no runtime dependency changes. The image installs with uv sync --locked from a uv image pinned by digest, and uv stays out of the final image. The backend and SSH jobs install from uv.lock; no publish, tag or release job or condition changes. No reference to Rye or to the removed lock files remains. The commit is verified, CI gate passes and Closes #527 matches the issue.

#523 changes .github/workflows/ci.yml and CONTRIBUTING.md, and #524 changes Dockerfile; the hunks do not touch. #526 uses this branch as its base, so retarget it to main before this branch is deleted, or the delete closes it.

Nits:

  • setup-uv has no version in the backend and SSH jobs, so CI runs the latest uv while the image pins 0.13.7. A required-version under [tool.uv], or a version on both steps, keeps the two on one installer.
  • Renovate now proposes updates for typer, click and rich, which pyproject.toml holds at old versions. #531 tracks lifting those holds.

@WilhelmZA WilhelmZA added dependencies Pull requests that update a dependency file reviewing Issue is being reviewed by maintainers labels Nov 20, 2026
@jsenecal
jsenecal merged commit cf43ba5 into main Nov 20, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python backend: API, models, state, execution ci Build, test and release pipelines container Docker image and compose dependencies Pull requests that update a dependency file docs Improve documentation reviewing Issue is being reviewed by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Python dependency locking from Rye to uv

3 participants