Skip to content

build: migrate to uv + pyproject.toml (PEP 621/735) + python-semantic-release - #253

Merged
bmtcril merged 1 commit into
openedx:mainfrom
farhan:farhan/modernize-python-repo-2
Oct 2, 2026
Merged

bmtcril merged 1 commit into
openedx:mainfrom
farhan:farhan/modernize-python-repo-2

Conversation

@farhan

@farhan farhan commented Sep 21, 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 `platform-plugin-aspects`
Part of openedx/public-engineering#506

Summary

  • Published to PyPI: https://pypi.org/project/platform-plugin-aspects/
  • 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/isort/pycodestyle/pydocstyle/black as on master.
  • Coverage config moved into `pyproject.toml`
  • Update CI to use `astral-sh/setup-uv`; SHA-pin all actions
  • Add `python-semantic-release` + `release.yml` (OIDC trusted publishing)
  • Add `commitlint.yml` to enforce conventional commit format on all future PRs to this repo

Removed/Updated

Deleted files: `setup.py`, `setup.cfg`, `requirements/`, `.coveragerc`, `.github/workflows/pypi-publish.yml`

Removed Makefile targets:

Target Reason
`piptools` pip-compile era bootstrap target; uv replaces pip-tools entirely

Updated Makefile targets:

Target Change
`requirements` Was `pip-sync -q requirements/dev.txt`; now `uv sync --group dev`
`upgrade` Was pip-compile invocation; now `uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml && uv lock --upgrade`
`extract_translations` Updated source paths from `platform_plugin_aspects/` to `src/platform_plugin_aspects/`
`compile_translations` Updated source paths from `platform_plugin_aspects/` to `src/platform_plugin_aspects/`
`format` Updated paths from `platform_plugin_aspects` to `src/platform_plugin_aspects`

Versioning

[Dynamic] `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

  • The `pypi-publish.yml` workflow was deleted because it used token-based authentication (`PYPI_UPLOAD_TOKEN`) and `python setup.py sdist bdist_wheel`, both of which are obsolete. It is replaced by `release.yml` which uses OIDC trusted publishing.
  • The CI `toxenv` matrix now uses `py` (instead of `django52`) since only one Django version is tested and it is declared as a runtime dependency in `[project].dependencies`.
  • `pip` and `wheel` from `pip.in` are not declared as explicit dependencies — they are build bootstrap tools that uv replaces entirely. The `pip<26.2` constraint is retained in `[tool.uv].constraint-dependencies`.
  • Baseline tag `v2.0.0` has been pushed so `python-semantic-release` can correctly identify the latest release.

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`, `pytest`, `python -m build`). Repo-owner is encouraged to run the repo's feature tests before merging.


🤖 Generated with Claude Code

@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch from eb00a70 to bca468d Compare September 21, 2026 15:30
@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch 3 times, most recently from a22bce9 to c4c4cbd Compare September 22, 2026 15:04
@farhan
farhan marked this pull request as ready for review September 28, 2026 08:07
Comment thread .readthedocs.yaml
Comment thread tox.ini
Comment thread pyproject.toml Outdated
@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch from 008e1b6 to 307bdd8 Compare September 30, 2026 08:58
Comment thread pyproject.toml Outdated
@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch from 008d221 to e8ecbb0 Compare September 30, 2026 11:13
@farhan
farhan requested review from bmtcril and feanil September 30, 2026 12:00
@farhan

farhan commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril I closed the older stale PR #237 and opened this. Salman has given 👍 on this PR, you can start doing its testing and review.

@feanil review is appreciated on this important PR.

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
@farhan

farhan commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@brian-smith-tcril

Could you test this on tutor-contrib-aspects when you get a chance, similar to this test-run?
When can we plan to merge this PR?

@bmtcril

bmtcril commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

I can test it later today

@saraburns1

Copy link
Copy Markdown
Contributor

@farhan can you please resolve the merge conflicts before we test?

@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch from 2d23a60 to f677998 Compare October 2, 2026 15:07
…-release

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@farhan
farhan force-pushed the farhan/modernize-python-repo-2 branch from f677998 to bca9dc9 Compare October 2, 2026 15:13
@farhan

farhan commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@saraburns1 conflicts resolved

@bmtcril

bmtcril commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Tests are running here: openedx/tutor-contrib-aspects#1343

@bmtcril bmtcril 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.

Looks good, the tutor-contrib-aspects tests all passed 👍

@bmtcril
bmtcril merged commit a933303 into openedx:main Oct 2, 2026
7 checks passed
@bmtcril

bmtcril commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

@farhan We got an error on CI of merging this that prevented release from going out:

Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 47, in run
    call = subprocess.run(
        args,
    ...<6 lines>...
        **kwargs,
    )
  File "/usr/local/lib/python3.14/subprocess.py", line 578, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('git', '--config-env=http.extraheader=GIT_EXTRA_HEADER', 'push', 'origin', 'python-coverage-comment-action-data')' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 106, in __call__
    return run(
        "git",
    ...<4 lines>...
        **kwargs,
    )
  File "/workdir/coverage_comment/subprocess.py", line 60, in run
    raise new_exc from exc
coverage_comment.subprocess.SubProcessError: Error on command: args=('git', '--config-env=http.extraheader=GIT_EXTRA_HEADER', 'push', 'origin', 'python-coverage-comment-action-data') returncode=1
stderr="To https://github.com/openedx/platform-plugin-aspects\n ! [remote rejected] python-coverage-comment-action-data -> python-coverage-comment-action-data (cannot lock ref 'refs/heads/python-coverage-comment-action-data': is at bc093411f7e98fd544fa6434fb7fcfb2730d89a0 but expected 55f2ee9ae3269e08335b34a26e937c78aadafce7)\nerror: failed to push some refs to 'https://github.com/openedx/platform-plugin-aspects'\n"
stdout=''
Launched from path=PosixPath('.') with kwargs={'env': {'PATH': '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOSTNAME': 'bb791642f6bb', 'COVERAGE_DATA_BRANCH': 'python-coverage-comment-action-data', 'GITHUB_RUN_ATTEMPT': '1', 'GITHUB_HEAD_REF': '', 'GITHUB_REF_NAME': 'main', 'GITHUB_ARTIFACTS': '/github/file_commands/artifacts_633192ef-6d6f-433b-a596-eda6e536b322', 'GITHUB_ACTIONS': 'true', 'INPUT_ANNOTATION_TYPE': 'error', 'SUBPROJECT_ID': '', 'GITHUB_ACTION': '__py-cov-action_python-coverage-comment-action', 'GITHUB_ACTION_REPOSITORY': 'py-cov-action/python-coverage-comment-action', 'RUNNER_ENVIRONMENT': 'github-hosted', 'RUNNER_WORKSPACE': '/home/runner/work/platform-plugin-aspects', 'ACTIONS_ORCHESTRATION_ID': '45a492b4-3ba0-8b70-b020-66f008e06027.run_ci.run_tests.ubuntu-24_04_3_12_py', 'COMMENT_ARTIFACT_NAME': 'python-coverage-comment-action', 'GITHUB_RETENTION_DAYS': '90', 'GITHUB_API_URL': 'https://api.github.com', 'GITHUB_REF_PROTECTED': 'true', 'GITHUB_WORKSPACE': '/github/workspace', 'RUNNER_NAME': 'GitHub Actions 1001448606', 'HOME': '/github/home', 'UV_PYTHON': '3.12', 'INPUT_GITHUB_PR_RUN_ID': '', 'INPUT_COVERAGE_DATA_BRANCH': 'python-coverage-comment-action-data', 'INPUT_COMMENT_ARTIFACT_NAME': 'python-coverage-c

I'll look more if I get time before you do.

@bmtcril

bmtcril commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Problem was a race since CI was basically running twice at the same time. More details and proposed fix are here: #257

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.

5 participants