Skip to content

build(packaging): publish DicoGIS on PyPI - #521

Merged
Guts merged 8 commits into
masterfrom
packaging/publish-to-pypi
Nov 6, 2026
Merged

Guts merged 8 commits into
masterfrom
packaging/publish-to-pypi

Conversation

@Guts

@Guts Guts commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Description

Makes DicoGIS publishable on PyPI, so that pip install dicogis / pipx install dicogis (already documented in the installation guide) can work.

  • build: require setuptools>=77. license = "Apache-2.0" is a PEP 639 SPDX expression, which older setuptools reject (reproduced with setuptools 76.1 and --no-isolation).
  • build: drop the unused setuptools-scm build requirement. It isn't configured, but as a build-time file finder it made the sdist embed every git-tracked file (11 MB instead of 0.5 MB) and the wheel ship the .ts translation sources, which package-data deliberately leaves out.
  • test: new tests/test_packaging.py checking that every .ui/.qm file is covered by [tool.setuptools.package-data], that no pattern matches nothing, and that the setuptools floor supports the SPDX license.
  • ci: the build and release workflow (builder_releaser.yml) now also handles the Python package, as QDT does. A build-python-package job builds the sdist and the wheel, runs twine check --strict and, on a tag, refuses a tag that doesn't match the package version (compared as PEP 440 versions). The release job attaches them to the GitHub release, and a release-pypi job publishes them from the pypi environment with Trusted Publishing (no API token). On pull requests touching pyproject.toml or MANIFEST.in, the package is only built and checked.
  • docs: docs/development/releasing.md describes the automated publication and the one-time setup, and the manual fallback is fixed. CLAUDE.md notes the packaging rules.

To do before the first release

  1. On PyPI, add a pending publisher: project dicogis, owner Guts, repository DicoGIS, workflow builder_releaser.yml, environment pypi.
  2. On GitHub, create the pypi environment (optionally with required reviewers).

Verification

  • Built the sdist and the wheel with python -m build: twine check --strict passes and the wheel contains the .ui, .qm, locale and bin files.
  • Ran the tag check of the workflow against the built wheel: matching tag passes, mismatching and non-version tags fail.
  • The new tests fail when the setuptools floor, a package-data pattern or a .ui location is broken on purpose.
  • pre-commit hooks pass on the changed files; tests.test_about and tests.test_packaging pass.
  • Not verified: the workflow on GitHub Actions, the full pytest suite (needs fixtures and PostGIS), and the availability of the dicogis name on PyPI (pip index versions found nothing, to be confirmed on pypi.org).

Related issue(s)

None.

Type of change

  • Bug fix (fix/… branch)
  • New feature or enhancement (feature/… branch)
  • Documentation (docs/… branch or *.md/docs/** changes)
  • Packaging / build (packaging/… branch or builder/** changes)
  • Tooling / CI-CD (tooling/… branch or .github/** changes)
  • Tests only (tests/** changes)

Checklist

  • I have read the Contributing Guidelines
  • pre-commit run --all-files passes locally
  • I have added or updated tests covering my changes
  • I have updated the documentation where relevant
  • pytest passes locally

AI/LLM disclosure

https://claude.ai/code/session_01HATwPxs2xpwnubZPvpGzBh


Generated by Claude Code

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci-cd Everything related to continuous integration and deployment packaging quality labels Oct 19, 2026
Comment thread .github/workflows/builder_releaser.yml Dismissed
Comment thread .github/workflows/builder_releaser.yml Dismissed
`license = "Apache-2.0"` is a PEP 639 SPDX expression, only understood by setuptools >= 77, while the build requirement allowed >= 64: a build without isolation (`python -m build --no-isolation`, as the manual release procedure used to do) with an older setuptools fails with a configuration error on `project.license`.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
setuptools-scm isn't configured (no `[tool.setuptools_scm]`, the version is single-sourced from `dicogis/__about__.py`) but, installed in the build environment, it still acts as a file finder: the sdist embedded every git-tracked file (documentation images, tests, CI configuration…) and weighed 11 MB instead of 0.5 MB, and the wheel shipped the `.ts` translation sources that `package-data` deliberately leaves out.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fails when a `.ui` or `.qm` file isn't covered by `[tool.setuptools.package-data]`, when a pattern matches nothing, or when the build requirements can't handle the SPDX license expression.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
New `pypi_publisher.yml` workflow: builds the sdist and the wheel, runs `twine check --strict`, refuses a tag that doesn't match the package version, then publishes from the `pypi` environment through OIDC (no API token). Run manually, or from a pull request touching the packaging files, it builds and checks without publishing.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Describe the automated publication and the one-time pending publisher setup, fix the manual fallback (no editable install nor `--no-isolation` needed, add the `twine check` step) and note the packaging rules in CLAUDE.md.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ease

Add a `build-python-package` job to the build and release workflow, as done in QDT: it builds the sdist and the wheel, runs `twine check --strict` and, on a tag, refuses a tag that doesn't match the package version. The distributions are attached to the GitHub release along with the executables, and rebuilt on pull requests touching `pyproject.toml` or `MANIFEST.in`.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HATwPxs2xpwnubZPvpGzBh
Add the `release-pypi` job, as done in QDT: on a tag, it uploads the distributions built by `build-python-package` from the `pypi` environment through Trusted Publishing (no API token). It replaces the standalone `pypi_publisher.yml` workflow, removed here, so that the executables, the GitHub release and the PyPI package come from a single workflow.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HATwPxs2xpwnubZPvpGzBh
… workflow

The package is now built, attached to the GitHub release and published to PyPI by `builder_releaser.yml`: update the release procedure, the workflow name to give to the PyPI pending publisher, and the packaging notes in CLAUDE.md.

AI-Level: 8 (bots planned, human approved)
AI-Model: claude-sonnet-5-5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HATwPxs2xpwnubZPvpGzBh
@Guts
Guts force-pushed the packaging/publish-to-pypi branch from 39242d6 to 7dddb36 Compare November 6, 2026 09:08
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.23%. Comparing base (9d57977) to head (7dddb36).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #521   +/-   ##
=======================================
  Coverage   78.23%   78.23%           
=======================================
  Files          54       54           
  Lines        3469     3469           
  Branches      435      435           
=======================================
  Hits         2714     2714           
  Misses        633      633           
  Partials      122      122           
Flag Coverage Δ
unittests 78.17% <ø> (ø)

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

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

@Guts
Guts merged commit d877c6b into master Nov 6, 2026
24 checks passed
@Guts
Guts deleted the packaging/publish-to-pypi branch November 6, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd Everything related to continuous integration and deployment documentation Improvements or additions to documentation packaging quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants