Skip to content

build: migrate to pyproject.toml - #264

Merged
uniqueg merged 2 commits into
devfrom
build/pyproject
Oct 17, 2026
Merged

uniqueg merged 2 commits into
devfrom
build/pyproject

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

First PR of the v0.14.0 maintenance series: move packaging from setup.py + requirements*.txt to PEP 621 metadata in pyproject.toml (setuptools backend). Dependency versions are unchanged here; they are updated in the next PR.

  • pyproject.toml with static metadata; version still read from foca/version.py
  • requires-python = ">=3.10" (Python 3.9 is EOL); Python 3.9 removed from the CI matrices
  • py.typed moved into the package, so it is actually shipped (previously the "Typing :: Typed" classifier was not true)
  • only foca* is packaged: tests is no longer installed as a top-level package into site-packages; pytest gets pythonpath = ["."] so the test suite still imports tests.*
  • typing_extensions declared as runtime dependency (imported in foca/models/config.py, previously only pulled in via pydantic)
  • removed: obsolete typing backport, unused toml; unused dev/docs deps (mypy-extensions, types-urllib3, types-setuptools, pylint (not run in CI), python-semantic-release, readthedocs-sphinx-ext); setup_requires; setuptools-git based MANIFEST.in; stale [semantic_release] config (pointed at master and a non-existent version variable)
  • mypy config moved to pyproject.toml; flake8 config stays in setup.cfg until ruff replaces flake8 (later PR)
  • Docker image installs FOCA straight from the source tree

Distribution name, import package and the dev/docs extras are unchanged, so pip install foca[dev] keeps working (unlike the Poetry approach in #251, whose ideas this supersedes; thanks @JaeAeich).

Closes #232

Verification

Locally (Python 3.12, uv):

  • uv build: sdist and wheel build; wheel contains foca/py.typed and access-control package data, top_level.txt is only foca, metadata has Requires-Python: >=3.10 and the same runtime requirements as before (minus typing/toml, plus typing_extensions)
  • pip install -e .[dev,docs], then flake8: clean; mypy foca: no issues in 32 files
  • pytest (unit tests without MongoDB): 246 passed
  • sphinx-build docs/api: succeeds

Not run locally (no MongoDB/Docker access in my environment): MongoDB-dependent tests (test_adapter.py, test_access_control_server.py, test_check_permission_*), Docker image build and petstore integration test; these are covered by CI.

CI: all checks pass (run): lint, mypy and unit tests incl. MongoDB-dependent tests on Python 3.10–3.12 × MongoDB 4.4–7.0, petstore integration tests, Docker builds (3.10–3.12), Codecov, Read the Docs.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Migrate project packaging and dependency management to a modern setuptools-based pyproject.toml configuration while dropping Python 3.9 support.

New Features:

  • Define project metadata, dependencies, optional extras, package data, and build configuration through PEP 621 in pyproject.toml.
  • Ship the typed-package marker and access-control resource files with the distribution.

Bug Fixes:

  • Declare typing_extensions as an explicit runtime dependency and ensure only the foca package is installed.

Enhancements:

  • Require Python 3.10 or newer and remove Python 3.9 from supported CI and Docker matrices.
  • Consolidate mypy and pytest configuration in pyproject.toml while preserving existing development and documentation installation extras.

Build:

  • Replace setup.py and requirements files with a setuptools-based pyproject.toml build configuration.
  • Update the Docker image build to install FOCA directly from the source tree.

Chores:

  • Remove obsolete packaging, dependency, and semantic-release configuration.

uniqueg and others added 2 commits October 17, 2026 18:05
Replace setup.py and the requirements*.txt files with PEP 621 metadata
in pyproject.toml (setuptools backend). Distribution name, import
package and the `dev` and `docs` extras are unchanged.

- declare `requires-python = ">=3.10"` (3.9 is end of life)
- ship `py.typed` inside the package so the "Typed" classifier holds
- package only `foca*`, so `tests` is no longer installed into
  site-packages; configure pytest `pythonpath` so tests still import
- declare `typing_extensions` as a runtime dependency (it is imported
  by `foca.models.config`)
- drop the obsolete `typing` backport and the unused `toml`,
  `mypy-extensions`, `types-urllib3`, `types-setuptools`, `pylint`,
  `python-semantic-release` and `readthedocs-sphinx-ext`
- drop `setup_requires` and the setuptools-git based MANIFEST.in
- remove the stale semantic-release config from setup.cfg; move the
  mypy config to pyproject.toml (flake8 config stays in setup.cfg until
  ruff replaces it)
- install FOCA directly from the source tree in the Docker image

Closes #232

Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA now requires Python >= 3.10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 16:06
@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Migrates FOCA from setup.py and requirements files to setuptools-backed PEP 621 metadata in pyproject.toml, preserving the distribution name, versioning, extras, and dependency versions while tightening package discovery and resource inclusion. The change also makes Python 3.10 the minimum supported version, explicitly declares typing_extensions, relocates tool configuration, and updates Docker and CI to use the new packaging flow.

Flow diagram for Docker installation from the source tree

flowchart LR
    Docker[Docker build]
    Inputs[pyproject.toml and foca source]
    Pip[pip install .]
    Image[Runtime image with FOCA and dependencies]

    Docker --> Inputs
    Inputs --> Pip
    Pip --> Image
Loading

File-Level Changes

Change Details Files
Replaces the legacy setuptools configuration and requirements files with PEP 621 metadata and a setuptools build backend.
  • Defines project metadata, runtime dependencies, development/docs extras, URLs, and Python 3.10+ support in pyproject.toml.
  • Keeps the package version dynamically sourced from foca.version and limits discovery to foca*.
  • Moves package data declarations for py.typed and access-control resources into setuptools configuration.
  • Removes setup.py, requirements files, obsolete build/development dependencies, and stale semantic-release configuration.
pyproject.toml
setup.py
setup.cfg
requirements.txt
requirements_dev.txt
requirements_docs.txt
MANIFEST.in
Adjusts packaging and test configuration so typed package data and test imports work with the new package layout.
  • Ships py.typed inside the foca package and preserves access-control YAML/config resources.
  • Stops installing tests as a package while configuring pytest to import tests from the repository root.
  • Declares typing_extensions explicitly as a runtime dependency and moves mypy settings into pyproject.toml.
pyproject.toml
MANIFEST.in
Updates container and CI workflows for the new packaging model and supported Python versions.
  • Removes Python 3.9 from CI and Docker test matrices.
  • Builds the Docker installation from pyproject.toml and the source tree instead of requirements.txt and setup.py.
.github/workflows/checks.yml
docker/Dockerfile

Assessment against linked issues

Issue Objective Addressed Explanation
#232 Migrate the project’s build and packaging configuration to Poetry in pyproject.toml, following the TESK example. ❌ The PR moves packaging metadata into pyproject.toml, but uses setuptools as the build backend rather than Poetry, so it does not fulfill the issue’s Poetry objective.

Possibly linked issues

  • #unknown: The PR declares pymongo~=4.7, which includes version 4.7.2 and addresses the requested PyMongo upgrade.

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 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (42300c6) to head (d0e5b40).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #264   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1113      1113           
=========================================
  Hits          1113      1113           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copilot AI 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.

🟢 Approval recommended

No blocking issues were identified in the packaging migration or its Docker and CI integration.

No open issues 🎉

What changed in this PR

Migrates FOCA packaging to setuptools-backed pyproject.toml, preserving the distribution name and extras while requiring Python 3.10+.

Changes:

  • Consolidates package metadata, dependencies, and tool configuration.
  • Limits installed packages to foca and includes typing and access-control data.
  • Updates Docker installation and removes Python 3.9 from CI.
File Description
setup.py Removes legacy packaging configuration.
setup.cfg Retains only flake8 configuration.
requirements.txt Moves runtime dependencies to project metadata.
requirements_docs.txt Moves retained documentation dependencies to extras.
requirements_dev.txt Moves retained development dependencies to extras.
pyproject.toml Defines packaging, dependencies, and tool settings.
MANIFEST.in Explicitly includes source-distribution test assets.
foca/​py.typed Places the typing marker inside the package.
docker/​Dockerfile Installs FOCA directly from source.
.github/​workflows/​checks.yml Removes Python 3.9 matrix entries.

Review effort: Balanced

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

@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 bd10f74 into dev Oct 17, 2026
20 checks passed
@uniqueg
uniqueg deleted the build/pyproject branch October 17, 2026 16:31
uniqueg added a commit that referenced this pull request Oct 17, 2026
Resolve conflicts with the squash-merged #264, #265 and #266:

- CI workflow: keep linting and format checks with ruff from this branch,
  take the commit-timestamp Docker tags from dev.
- Release workflow: take the release commit check and skip-existing
  uploads from dev.
- pyproject.toml: keep ruff and pre-commit instead of flake8 in the dev
  extra.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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: use Poetry and pyproject.toml

2 participants