Skip to content

feat: modernize Python tooling (pyproject.toml + uv + semantic-release) - #590

Open
irfanuddinahmad wants to merge 17 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/uv-migration
Open

irfanuddinahmad wants to merge 17 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/uv-migration

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves openedx-events to pyproject.toml, uv and python-semantic-release. Part of openedx/public-engineering#514 (parent openedx/public-engineering#506).

  • setup.py and setup.cfg replaced by pyproject.toml. The version now comes from git tags via setuptools-scm.
  • pip-tools requirements/ replaced by uv dependency groups and uv.lock. Django 4.2 and 5.2 share one lock through [tool.uv].conflicts.
  • Package moved to the src/ layout.
  • tox, Makefile, CI and Read the Docs run through uv.
  • release.yml matches openedx/sample-plugin: semantic-release with GITHUB_TOKEN, and PyPI publishing through OIDC trusted publishing. This replaces pypi-publish.yml and its token.

CHANGELOG.rst stays. .coveragerc settings moved into pyproject.toml. pylintrc and ruff.toml are unchanged.

Before merging

  • PyPI trusted publisher configured for openedx-events (repo openedx/openedx-events, workflow release.yml)

The v11.2.0 tag exists, so the first automated release continues from 11.2.0.

Testing

  • All 117 tests pass on Django 4.2 and 5.2.
  • quality and docs pass.
  • The built wheel reports version 11.2.0.

Reviewer notes

  • Add type hinting across the package #565 (type hints) touches the same files, so it's worth agreeing on merge order with its author.
  • To test a new Django version, add a test-djangoXY group and extend [tool.uv].conflicts.

🤖 Generated with Claude Code

Irfan Ahmad and others added 3 commits July 15, 2026 08:27
Replace setup.py/setup.cfg with PEP 621 [project] metadata and
setuptools-scm for git-tag-based versioning. openedx_events/__init__.py's
__version__ (used at runtime by data.EventData.sourcelib) now derives from
importlib.metadata instead of a hand-maintained string. The [bumpversion]
section in setup.cfg is dropped along with the file -- setuptools-scm now
owns versioning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace requirements/*.in + *.txt with PEP 735 dependency-groups in
pyproject.toml and a single uv.lock. Update tox.ini to use tox-uv's
uv-venv-lock-runner, update the Makefile, and switch ci.yml to install uv
and run via `uv run tox` / `uv sync`. Django 4.2/5.2 are declared as
mutually-conflicting dependency-group forks via [tool.uv].conflicts so
both coexist in one lock. quality/doc groups preserve the existing
pylint + pycodestyle + isort + ruff (docstring-only) toolchain unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Configure python-semantic-release: pushes to main with conventional
commits now automatically bump the version, tag it, and publish to PyPI
via OIDC trusted-publisher auth (id-token: write, no stored credentials),
replacing the old release-triggered publish.yml token-based flow.
commitlint.yml already enforces conventional commits in this repo, so no
separate commit is needed for that piece.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/committers-openedx-events.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 15, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 15, 2026
Irfan Ahmad and others added 3 commits July 15, 2026 08:43
Three related CI failures found after opening this PR:

- pyproject.toml: fallback_version was "0.0.0.dev0" -- data.EventData.sourcelib
  parses __version__ via tuple(map(int, __version__.split("."))), and "dev0"
  isn't a valid int, so any environment without visible tags crashed 17 tests
  with ValueError. Changed to "0.0.0" (still a placeholder, but int-parseable).
- ci.yml: actions/checkout defaults to a shallow, tag-less clone, so
  setuptools-scm could never see real tags in the tests job and always fell
  back regardless of the fallback_version fix above. Added fetch-depth: 0.
  (release.yml's checkout doesn't need this -- python-semantic-release's own
  action auto-deepens a shallow clone before evaluating version history.)
- .readthedocs.yaml: still pointed at requirements/doc.txt, deleted in the
  prior commit. Switched to RTD's custom-build-command escape hatch (uv sync
  + sphinx-build), matching the pattern already used in openedx/edx-enterprise#2654.

Verified by simulating CI's actual shallow/no-tags checkout locally
(git clone --depth 1 --no-tags) and confirming all 109 tests pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
codecov.yml requires 100% patch coverage. The except branch added in the
metadata-consolidation commit can't be exercised in CI/tests (the package
is always installed), so codecov/patch correctly flagged it as an
uncovered new line. Mark it pragma: no cover rather than contriving a test
for an environment that can't occur here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@release/v1 is a floating branch ref -- xblocks-core's release just failed
with "docker: manifest unknown" because the Docker image tag it resolved to
at checkout time wasn't published on ghcr.io yet. Pin to the exact commit
backing the current v1.14.0 release instead, consistent with this repo's
own SHA-pinning rule for every other action.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 15, 2026
@mphilbrick211
mphilbrick211 requested a review from a team July 15, 2026 14:44
Reviewer feedback: this should be set across the whole batch, not just
repos currently on 0.x, so no repo in this effort can ever auto-jump to
1.0.0 as an accidental side effect if it's reset to 0.x in the future.
Note this is a no-op for repos already past 1.0 -- major_on_zero only
governs the 0.x -> 1.0.0 transition, not 1.x -> 2.0.0 (there's no PSR
setting that suppresses major bumps once past 1.0; that's normal SemVer
behavior for a breaking-change commit at any version).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@farhan
farhan self-requested a review July 16, 2026 10:42
Irfan Ahmad and others added 2 commits July 17, 2026 10:08
openedx/sample-plugin -- the reference implementation this whole
modernization effort points at -- already uses src-layout, which this
repo's earlier pyproject.toml migration didn't follow. Move the package
under src/ and update every path reference that assumed the old flat
layout:

- pyproject.toml: add where = ["src"] to packages.find
- tox.ini: prefix src/ onto the package name in pylint/pycodestyle/ruff/
  isort quality-env commands
- Makefile: same prefix in the isort convenience target; also drops a
  stale reference to setup.py (deleted in the earlier metadata-migration
  commit, left behind here)
- MANIFEST.in: same prefix on the recursive-include line

No other path-sensitive helpers found in this repo (no in-package here()/
root() climb, no Dockerfile, docs/conf.py has no sphinx-apidoc call to
fix -- simplest of the 7 library repos in this batch).

Verified: uv sync against the committed lockfile (no re-lock), full tox
matrix (django42, django52, quality, docs) all green, uv build --wheel +
twine check pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Same category of fixes farhan flagged on the batch's other reviewed PRs:

- ci.yml: add enable-cache/python-version to astral-sh/setup-uv and drop
  the now-redundant actions/setup-python step (fetch-depth: 0 was already
  correctly set here and is untouched)
- pyproject.toml: add [tool.uv] package = true
- Drop CHANGELOG.rst from the dynamic readme file list and delete it --
  python-semantic-release + GitHub Releases is the changelog of record
- Migrate .coveragerc into [tool.coverage.run] and delete the old file
- MANIFEST.in: also fixed a previously-noted-but-unfixed gap from this
  repo's src-layout commit -- `include requirements/base.in` and
  `include requirements/constraints.txt` referenced files deleted long
  ago as part of the uv migration; removed both alongside the
  CHANGELOG.rst include

Verified: uv sync (no lock drift), full django52 test run (109 passed),
quality and docs envs pass end to end -- docs env's apidoc + wheel build
+ twine check confirm the readme/coverage/MANIFEST.in changes work.
Comment thread CHANGELOG.rst
@mariajgrimaldi

mariajgrimaldi commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Here's the bump that was blocking the PR: #593 - but we do have a gh tag matching https://github.com/openedx/openedx-events/tree/v11.2.0 so I'm not sure if it's necessary since all we've done is maintenance on the repo

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Aug 19, 2026
irfanuddinahmad and others added 4 commits August 31, 2026 17:12
…migration

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/pypi-publish.yml
#	requirements/base.txt
#	requirements/ci.txt
#	requirements/dev.txt
#	requirements/doc.txt
#	requirements/pip-tools.txt
#	requirements/pip.txt
#	requirements/quality.txt
#	requirements/test.txt
Makefile now assumes an already-synced/activated local env; uv run
stays in CI workflow steps only. See openedx/ccx-keys#190 (review
comment r4097501942).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…gration

Resolve conflicts with main: drop the requirements/*.txt and *.in files
the migration removed, keep CHANGELOG.rst, move the new tasks.py under
src/, and add celery (new in base.in on main) to dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read the version straight from package metadata, matching the other
migrated repos. The package is always installed in dev, CI and prod.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml
Comment thread .readthedocs.yaml Outdated
Comment thread pyproject.toml

@mariajgrimaldi mariajgrimaldi left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you so much for this :))

We can merge this once @salman2013's comments are addressed :)

irfanuddinahmad and others added 2 commits October 13, 2026 18:38
- release.yml: match openedx/sample-plugin (GITHUB_TOKEN, PSR v10.7.0,
  vcs_release false + gh release create with dist attached)
- .readthedocs.yaml: install via RTD's native uv support, keep
  fail_on_warning, pin build.os to ubuntu-26.04
- authors: Open edX Project <oscm@openedx.org>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Set include-package-data = false, as setup.py had it. With it on,
setuptools-scm pulled every tracked file under the package into the
wheel, including 72 test schema files. The wheel now matches 11.2.0
on PyPI (plus the new tasks.py). Also drop the isort migrations skip,
which wasn't in setup.cfg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
irfanuddinahmad and others added 2 commits October 22, 2026 15:17
Keep requirements/*.txt deleted; they are replaced by uv.lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…recated

serve_docs no longer re-syncs the env (dev already includes doc). Set
tag_format explicitly with the standard comment, and point CHANGELOG.rst
at GitHub Releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

5 participants