Skip to content

build: modernize packaging with uv, pyproject.toml and semantic-release - #486

Merged
feanil merged 1 commit into
openedx:masterfrom
farhan:farhan/modernize-python-repo
Nov 6, 2026
Merged

feanil merged 1 commit into
openedx:masterfrom
farhan:farhan/modernize-python-repo

Conversation

@farhan

@farhan farhan commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Important

PR implemented with the assistance of Claude Code. Refined and validated before being submitted for code review.

Modernize django-config-models
Part of openedx/public-engineering#506

Summary

  • Published to PyPI as django-config-models.
  • Move the package into a src/ layout.
  • Replace setup.py/setup.cfg with pyproject.toml (PEP 621 static metadata).
  • Switch from pip-compile to uv with PEP 735 dependency groups; commit uv.lock.
  • Retain pylint/pycodestyle/pydocstyle as on master.
  • Move .coveragerc and the tox [pytest] config into pyproject.toml.
  • Update CI to use astral-sh/setup-uv; SHA-pin all actions; set ci.yml token permissions: contents: read.
  • Add python-semantic-release + release.yml (OIDC trusted publishing), replacing publish_pypi.yml.

Removed/Updated

Deleted files: setup.py, setup.cfg, requirements/, .coveragerc, .github/workflows/publish_pypi.yml

Removed Makefile targets:

Target Reason
compile-requirements pip-compile is replaced by uv lock

Updated Makefile targets:

Target Change
requirements uv sync --locked --group dev instead of pip-sync; dev includes doc so make docs works after it
upgrade edx_lint write_uv_constraints + uv lock --upgrade instead of pip-compile
quality Runs pylint/pycodestyle directly (was tox -e quality); tox now calls this target
docs Runs sphinx-apidoc/Sphinx/build/twine directly (was tox -e docs); tox now calls this target
test Sets DJANGO_SETTINGS_MODULE and adds mock_apps to PYTHONPATH so it works outside tox; tox now calls this target
dummy_translations Path updated for the src/ layout

Versioning

setuptools-scm with dynamic = ["version"] — master had a PyPI publish workflow; python-semantic-release controls the version string at release time via git tags.

Important Notes

  • license is set to AGPL-3.0-or-later from master's GNU Affero General Public License v3 or later (AGPLv3+) classifier (setup.py also had license="AGPL 3.0").
  • CI toxenv names (quality, docs, django52-drflatest, check_keywords) are unchanged so branch-protection check names stay the same.
  • CHANGELOG.rst is kept with a deprecation note and still ships in the sdist, as on master; release notes now live on GitHub Releases.
  • uv.lock is seeded from master's requirements/*.txt pins, so dependency versions match master; upgrades are left to the first make upgrade.
  • The README CI badge now tracks release.yml, since ci.yml no longer runs on pushes to master.
  • [tool.semantic_release] sets tag_format = "v{version}" (matches existing tags such as v3.0.0), major_on_zero = false and allow_zero_version = true explicitly, so releases don't depend on PSR defaults.
  • commitlint.yml already existed, so conventional commit format is enforced and now also drives releases (fix: → patch, feat: → minor).
  • tox and the Makefile now run the other way round: tox envs call Makefile targets (make test, make quality, make docs, make check_keywords), whereas on master tox ran the commands itself. This goes beyond the migration and is intentional. Running make docs locally now also builds the dist and runs twine check, which master only did inside tox -e docs.

Testing Notes

This PR has not been manually tested against the repo's own features. Testing relied on CI checks and local agent tooling (make requirements, make quality, make test, make docs, python -m build). Repo-owner is encouraged to run the repo's feature tests before merging.


🤖 Generated with Claude Code

@farhan
farhan marked this pull request as ready for review October 30, 2026 06:26
@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (42eaabf) to head (60ce03e).

Additional details and impacted files
@@      Coverage Diff      @@
##   master   #486   +/-   ##
=============================
=============================

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

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

uv.lock was resolved fresh, so this upgrades most of master's pins (e.g. Django 5.2.14→5.2.18, python-dateutil 2→3). Per feanil on enterprise-access#1015, the migration should keep master's versions: seed the lock from requirements/*.txt (add them as == to constraint-dependencies, uv lock, restore, uv lock again) and leave upgrades to the first make upgrade.

Also, dev doesn't include the doc group, so make requirements && make docs fails on a fresh clone. Adding {include-group = "doc"} to dev fixes it. docs/getting_started.rst and docs/testing.rst still describe a virtualenv setup.

Since ci.yml no longer runs on pushes to master (CI now runs inside release.yml), the README "Python CI" badge will stay stuck on its last pre-migration result; XBlock's still shows June's. Pointing it at actions/workflows/release.yml/badge.svg?branch=master, or dropping it, fixes that.

@farhan

farhan commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed in f9f2152.

@irfanuddinahmad irfanuddinahmad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add tag_format = "v{version}", major_on_zero = false and allow_zero_version = true to [tool.semantic_release], use fallback_version = "0.0.0", and add a top-level permissions: contents: read to ci.yml, since run_ci now calls it from release.yml.

This flips the Makefile/tox direction (tox now calls make). Fine by me since it's the direction feanil prefers, but it's beyond the migration itself, so flag it in the description. Here it also makes make docs build and twine-check a dist.

@farhan
farhan force-pushed the farhan/modernize-python-repo branch from 7364286 to 2c2b09a Compare November 3, 2026 06:19
Move to PEP 621 metadata, PEP 735 dependency groups locked with uv, a
src/ layout and python-semantic-release with OIDC publishing, as part
of the Python repo modernization effort (openedx/public-engineering#506).

uv.lock is seeded from master's requirements/*.txt pins so the switch is
like-for-like; upgrades are left to the first `make upgrade`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch from 2c2b09a to 90e703e Compare November 3, 2026 06:25
@farhan
farhan requested a review from feanil November 3, 2026 15:45
@feanil
feanil merged commit a768b55 into openedx:master Nov 6, 2026
7 checks passed
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.

3 participants