Skip to content

build: declare dependencies in pyproject.toml - #142

Merged
uniqueg merged 3 commits into
devfrom
build/pyproject-deps
Oct 21, 2026
Merged

uniqueg merged 3 commits into
devfrom
build/pyproject-deps

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #135.

  • pyproject.toml: the runtime dependencies are in [project] dependencies, the development and documentation dependencies in the dev and docs extras ([project.optional-dependencies]), as in FOCA. The exact pins of requirements_dev.txt and requirements_docs.txt become ranges: lower bounds at the versions pinned so far; upper bounds (next major) for the runtime and docs dependencies, as FOCA has them; the environment marker of tomli stays. dynamic is now only ["version"].
  • requirements.txt, requirements_dev.txt, requirements_docs.txt: deleted; nothing refers to them any more.
  • Dockerfile (and .dockerignore): the dependency layer copies only pyproject.toml and installs project.dependencies (read with tomllib), so that code changes still do not reinstall the dependencies; the app is installed with --no-deps as before.
  • CI (checks.yaml): pip install -e ".[dev]" (lint, tests, Helm) and pip install -e ".[docs]" (docs); the pip cache is keyed on pyproject.toml. The publish job installed setuptools-scm with requirements_dev.txt as a constraint; it now runs pip install "setuptools-scm>=8" (the bound of build-system.requires), as FOCA's workflow does. release.yaml used none of the files.
  • Read the Docs: installs the package with the docs extra.
  • Dependabot: the pip entry now reads pyproject.toml, uses FOCA's versioning-strategy: increase-if-necessary, and ignores minor and major updates of foca, like the docker entry for elixircloud/foca, so that the base image and the foca requirement are bumped together by hand; comments updated.
  • Comments: pyproject.toml (setuptools-scm note), .pre-commit-config.yaml (local hooks), .github/dependabot.yml.
  • Docs: only the install commands in docs/development.md that named the requirements files (now pip install -e ".[dev]" and pip install -e ".[docs]") and the wording "dev dependencies" next to them; no other prose.
  • Test: test_base_image_foca checks that the FOCA version of the base image satisfies the foca requirement (written first; it failed on dev, where pyproject.toml has no dependencies).

Trade-off: with lower-bound-only ranges, Dependabot no longer opens pull requests for the dev dependencies (any new version already satisfies them), and CI installs their latest versions, as in FOCA, so a new release of e.g. mypy or setuptools-scm can change CI results without a commit. The docs dependencies are bounded by major version only, so a minor release that adds a warning can fail the strict build. Locked, hash-checked installs stay out of scope (#125).

How it was verified

Locally (Python 3.12 venv with pip 24.0, as in CI; MkDocs on 3.12; Docker is not available here, so the image build and the smoke test ran only in CI):

  • pip install -e ".[dev,docs]": installs every package of the three old files, at the versions pinned so far (pip freeze); python -m build: wheel metadata lists the runtime dependencies and both extras
  • Python 3.10 (uv pip install -e ".[dev]"): installs tomli; pytest tests/test_config.py tests/test_version.py: passed
  • coverage run --source=cloud_registry -m pytest -W ignore::DeprecationWarning (with Helm): 727 passed, coverage 100%
  • test_base_image_foca: failed before the change (KeyError: 'dependencies') and with a mismatching foca range, passes now
  • ruff 0.17.1 (check, format --check), mypy, ast-grep scan, ast-grep test --skip-snapshot-tests, actionlint: pass
  • mkdocs build --strict: passes
  • The tomllib one-liner of the Dockerfile run with sh -c: prints the four runtime dependencies

CI (run 39645264472): all checks pass, including the Docker Compose smoke test (image build), the docs build, Read the Docs, codecov/patch and codecov/project.

Declined review findings

  • Upper bounds (or exact pins) for the dev tools, to keep CI reproducible (adversarial and quality review): the issue asks for ranges as FOCA has them; FOCA's dev extra has lower bounds only; locked installs are build: install locked, hash-checked dependencies #125. Noted as a trade-off above.
  • Reading only project.dependencies in a separate build stage, so that edits of other sections of pyproject.toml keep the dependency layer cached: more Dockerfile machinery for a cache that CI builds don't have; the base image is pinned and has Python 3.12 (tomllib), noted in the comment.
  • One canonical comment for the manual FOCA bumps instead of short notes in pyproject.toml and the Dockerfile: each note points to .github/dependabot.yml, where the rule is.
  • A negative test case for test_base_image_foca: checked by hand with a mismatching range (see above).

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Centralize dependency declarations in pyproject.toml and migrate packaging, container builds, automation, and documentation to use the new dependency extras.

New Features:

  • Declare runtime, development, and documentation dependencies in pyproject.toml with appropriate version ranges and extras.

Bug Fixes:

  • Ensure the Docker base image's FOCA version remains compatible with the package's declared FOCA requirement.

Enhancements:

  • Replace legacy requirements files with standard package extras across development, documentation, CI, Read the Docs, and dependency update configuration.
  • Keep Docker dependency installation cached independently from application code changes.

CI:

  • Update CI dependency installation and caching to use pyproject.toml extras.
  • Adjust publishing version calculation to install the build-system's supported setuptools-scm range.

Deployment:

  • Update the Docker image dependency layer to derive runtime dependencies from pyproject.toml.

Documentation:

  • Update development documentation to use the new dev and docs package extras.

Tests:

  • Add coverage verifying that the Docker base image's FOCA version satisfies the declared dependency requirement.

Chores:

  • Remove the obsolete runtime, development, and documentation requirements files.

uniqueg and others added 3 commits October 21, 2026 19:24
Move the runtime dependencies into `project.dependencies` and the
development and documentation dependencies into the `dev` and `docs`
extras, as FOCA does, and delete the three `requirements*.txt` files.
The exact pins of the dev and docs dependencies become version ranges.

The image installs the dependencies from `pyproject.toml` before the
code, so that code changes still do not reinstall them, and CI installs
the build requirements to compute the version of dev images. Dependabot
reads `pyproject.toml` and ignores minor and major updates of `foca`,
as for the base image, so that both are bumped together; a test checks
that the base image satisfies the `foca` requirement.

Closes #135

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Install setuptools-scm for the version of dev images as FOCA does, set
Dependabot's versioning strategy of FOCA, note that the bounds of the
docs dependencies allow minor releases, and make the base image test
report mismatches clearly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR consolidates dependency management in pyproject.toml, replaces requirements-file installations with project extras throughout CI, Docker, documentation hosting, and developer instructions, and adds a consistency check between the Docker base image and the declared FOCA requirement.

Sequence diagram for Docker dependency-layer caching

sequenceDiagram
    participant Docker as Docker build
    participant Project as pyproject.toml
    participant Python as Base image Python
    participant Pip as pip
    participant App as Application source

    Docker->>Project: COPY pyproject.toml
    Docker->>Python: tomllib.load(project)
    Python-->>Docker: project.dependencies
    Docker->>Pip: pip install -r /tmp/src/requirements.txt
    Docker->>App: Install application with --no-deps
Loading

Flow diagram for dependency consistency validation

flowchart LR
    B[FOCA base image version]
    P[pyproject.toml foca requirement]
    T[test_base_image_foca]
    V{Version satisfies requirement?}
    Pass[Check passes]
    Fail[Check fails]

    B --> T
    P --> T
    T --> V
    V -->|yes| Pass
    V -->|no| Fail
Loading

File-Level Changes

Change Details Files
Moves runtime, development, and documentation dependency declarations from requirements files into project metadata with bounded or lower-bound version ranges.
  • Adds runtime dependencies under [project].dependencies.
  • Adds dev and docs extras under [project.optional-dependencies], including the Python 3.10 tomli marker.
  • Removes dynamic dependency loading and deletes the three requirements files.
  • Updates developer documentation, Dependabot, pre-commit comments, and packaging metadata references.
pyproject.toml
requirements.txt
requirements_dev.txt
requirements_docs.txt
docs/development.md
.github/dependabot.yml
.pre-commit-config.yaml
Updates dependency installation and caching across container builds, CI, and documentation hosting to consume the new extras and project metadata.
  • Extracts project.dependencies from pyproject.toml with tomllib for the cached Docker dependency layer, then installs the application with existing no-deps behavior.
  • Installs dev or docs extras in the corresponding CI jobs and keys pip caching on pyproject.toml.
  • Installs the docs extra in Read the Docs and updates the publish job's setuptools-scm constraint.
Dockerfile
.dockerignore
.github/workflows/checks.yaml
.readthedocs.yaml
Adds a regression test ensuring the Docker base image's FOCA version satisfies the declared runtime requirement.
  • Parses the FOCA requirement from pyproject.toml and the base image version from Dockerfile.
  • Fails when the base image version falls outside the declared requirement range.
tests/test_config.py

Assessment against linked issues

Issue Objective Addressed Explanation
#135 Declare runtime, development, and documentation dependencies in pyproject.toml as project dependencies and optional extras, preserving the tomli environment marker and using version ranges. ✅
#135 Delete the three requirements*.txt files and remove references to them throughout project configuration, workflows, documentation, and comments. ✅
#135 Update image building, CI and release-related workflows, Read the Docs, and dependency management to use the new dependency declarations while preserving the existing build and documentation behavior. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5e95450) to head (7e34809).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #142   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          737       737           
=========================================
  Hits           737       737           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 21, 2026 17:41

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg
uniqueg merged commit 3b51c36 into dev Oct 21, 2026
12 checks passed
@uniqueg
uniqueg deleted the build/pyproject-deps branch October 21, 2026 17:48
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.

build: declare dependencies in pyproject.toml

1 participant