Skip to content

feat: modernize openedx-authz to uv + pyproject.toml + semantic-release - #371

Open
irfanuddinahmad wants to merge 4 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/modernize-python-tooling
Open

feat: modernize openedx-authz to uv + pyproject.toml + semantic-release#371
irfanuddinahmad wants to merge 4 commits into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/modernize-python-tooling

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Modernize openedx-authz to src/ layout + uv + pyproject.toml (PEP 621/735) + python-semantic-release.

Part of openedx/public-engineering#506 (tracked in #516).

  • Move openedx_authz/ to src/openedx_authz/ (per the 2026-07-15 decision on #506)
  • Replace setup.py/setup.cfg with pyproject.toml (PEP 621 static metadata); .coveragerc folded into [tool.coverage.*]
  • Switch from pip-compile to uv with PEP 735 dependency groups; commit uv.lock
  • Update tox.ini to use tox-uv with uv-venv-lock-runner
  • Update CI to use astral-sh/setup-uv, SHA-pin the actions that need it
  • Add python-semantic-release + release.yml, replacing the old tag-triggered pypi-publish.yml; publish to PyPI via OIDC

Removed

Deleted files: setup.py, setup.cfg, .coveragerc, requirements/ (all .in/.txt files), .github/workflows/pypi-publish.yml

Not included

No ruff/lint-tooling changes beyond what already existed — this migration is tooling-only.

Versioning

Dynamic — setuptools-scm derives the package version from git tags. Confirmed the latest git tag matches the latest version actually published on PyPI (1.21.1), so the first automated release should compute a version strictly newer than that.

Testing Notes

Verified locally: uv lock resolves cleanly, uv sync --group dev succeeds, uv run tox passes, python -m build produces a correctly-versioned wheel with tests excluded.

Could not verify locally (needs CI / a maintainer):

  • PyPI trusted publisher (OIDC) is not yet confirmed configured for openedx-authz — not a blocker to merging, but the first automated release will fail at the publish_to_pypi job until it's set up.
  • Whether the OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN org secret is configured for this repo.
  • .github/workflows/upgrade-python-requirements.yml calls openedx/.github's shared reusable workflow, which hardcodes add-paths: requirements with no override input — now that requirements/ is deleted, that scheduled job will keep running but silently stop producing real dependency-upgrade PRs. Fix needs to land in openedx/.github, not this repo.

Code reviewer notes

release.yml's action pins intentionally match openedx/XBlock's actual, already-releasing release.yml: plain version tags for python-semantic-release, publish-action, upload-artifact, download-artifact; only pypa/gh-action-pypi-publish is SHA-pinned (documented @release/v1 floating-branch bug), pinned to the verified commit SHA (not the tag object's SHA).


This PR was created with Claude Code.

Adopt the src/ layout for openedx_authz per the 2026-07-15 decision on
openedx/public-engineering#506: move openedx_authz/ -> src/openedx_authz/
so editable installs resolve correctly for tools like mypy (flat-layout
editable installs are not reliably resolvable).

Update every hardcoded flat-path reference to the new location:
MANIFEST.in, .coveragerc source, docs/conf.py (version-file path and the
sphinx-apidoc source paths), tox.ini (pytest --cov/--ignore and the
quality testenv's pylint/ruff/pydocstyle targets), and the Makefile's
translation targets (extract/compile/detect/pull/dummy_translations,
ruff format/check).

pyproject.toml's [tool.setuptools.packages.find] where=["src"] wiring
lands in the next commit alongside the rest of the metadata migration.
Replace setup.py/setup.cfg with PEP 621 static metadata in
pyproject.toml. setuptools-scm now derives the version from git tags
(fallback_version = "0.0.0"); the hardcoded __version__ in
openedx_authz/__init__.py is removed since nothing else in the repo
reads it beyond docs/conf.py, which now gets the version via
importlib.metadata instead of regex-parsing __init__.py.

Coverage configuration is consolidated from .coveragerc into
[tool.coverage.*]. The dead [isort]/[wheel] settings from setup.cfg are
ported into [tool.isort] verbatim (import sorting is actually enforced
via ruff's "I" rule per the CHANGELOG's prior pycodestyle/isort -> ruff
migration, but the old isort section is preserved rather than silently
dropped).

Also fixes a pre-existing MANIFEST.in/README.rst mismatch: the repo's
license file is named `LICENSE` (no extension), but both referenced the
nonexistent `LICENSE.txt`.

Part of openedx/public-engineering#506, tracked in #516.
Replace requirements/*.in/*.txt with PEP 735 dependency groups in
pyproject.toml (test-base, test, quality, doc, ci, dev), resolved into
a committed uv.lock. Populate [tool.uv].constraint-dependencies via
`edx_lint write_uv_constraints` and add the (currently empty)
[tool.edx_lint].uv_constraints override point.

Update tox.ini to use tox-uv (uv-venv-lock-runner) and dependency_groups
instead of -r requirements/*.txt. Update the Makefile's upgrade/quality/
format/requirements/test/diff_cover/test-all targets to go through
`uv run`/`uv sync`/`uv lock` instead of pip-compile/pip-sync. Update
.readthedocs.yaml to install via `uv sync --group doc`. Drop the now-
stale requirements/ references from MANIFEST.in and .gitignore.

Update the CI workflow to install uv via astral-sh/setup-uv (SHA-pinned,
with caching), sync via `uv sync --group ci`, and run each tox env via
`uv run tox -e <env>`; add `fetch-depth: 0` so setuptools-scm can see
tags during test runs, and `permissions: contents: read`.

While verifying the full tox matrix locally post-migration, found and
fixed a real bug surfaced by the src/ layout move: three tests in
test_enforcer.py opened `openedx_authz/engine/config/{model.conf,
authz.policy}` as paths relative to the process cwd rather than via the
package's own ROOT_DIRECTORY (as settings/common.py and settings/test.py
already correctly do), so they broke once the package moved under src/.

Part of openedx/public-engineering#506, tracked in #516.
Add python-semantic-release configuration to pyproject.toml
(major_on_zero = false, allow_zero_version = true; build_command uses
python -m build since python-semantic-release's action environment
doesn't have uv available) and a release.yml workflow that runs the CI
suite, cuts a release with python-semantic-release on pushes to main,
and publishes to PyPI via OIDC trusted publishing (no stored API
token). ci.yml now triggers on workflow_call instead of push, since
release.yml owns that path (avoids running the suite twice on main).

Replace the old tag-triggered, token-based pypi-publish.yml (built
`python setup.py sdist bdist_wheel` and used an unpinned
`pypa/gh-action-pypi-publish@release/v1` ref with a stored
PYPI_UPLOAD_TOKEN) -- it would otherwise race release.yml's OIDC
publish on the first semantic-release tag. pypa/gh-action-pypi-publish
is pinned to a commit SHA (release/v1 is a floating branch, not a
version tag: confirmed root cause of a real production failure on a
sibling repo in this effort); the python-semantic-release and
actions/{upload,download}-artifact actions use plain version tags
matching openedx/XBlock's actual, currently-releasing release.yml,
per the org-wide lesson that hand-verified SHA pins for those four
actions were wrong in 3 of 5 audited sibling PRs.

Pre-flight check: latest git tag v1.21.1 (via --sort=-v:refname)
matches the version currently live on PyPI (1.21.1).

Part of openedx/public-engineering#506, tracked in #516.
@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 28, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

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

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.

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: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants