Skip to content

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

Open
irfanuddinahmad wants to merge 5 commits into
openedx:masterfrom
irfanuddinahmad:irfanuddinahmad/uv-migration
Open

irfanuddinahmad wants to merge 5 commits into
openedx:masterfrom
irfanuddinahmad:irfanuddinahmad/uv-migration

Conversation

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

Summary

Moves edx-completion from setup.py/pip-tools to pyproject.toml, uv and python-semantic-release.

Part of openedx/public-engineering#512 (parent openedx/public-engineering#506).

  • Package metadata, isort and coverage config now live in pyproject.toml. The version comes from setuptools-scm, and __version__ is read with importlib.metadata. The license is AGPL-3.0-or-later, matching the old "v3 or later" classifier.
  • requirements/ is replaced by dependency groups and uv.lock. The DRF matrix maps to the drf314 and test groups, which are declared as [tool.uv].conflicts so each gets its own resolution.
  • Global caps such as Django<6.0 now come from edx_lint write_uv_constraints into constraint-dependencies. The Makefile no longer downloads common_constraints.txt.
  • tox uses tox-uv (uv-venv-lock-runner). CI uses setup-uv, uv sync --locked --group ci and uv run --locked tox, and now also runs the existing docs env. A workflow_call trigger was added so the release can reuse CI.
  • release.yml comes from openedx/sample-plugin, with only the monorepo parts removed. It publishes to PyPI with trusted publishing. The token-based pypi-publish.yml is removed.

Before merging

  • PyPI trusted publisher configured for edx-completion: repo openedx/completion, workflow release.yml.
  • v5.0.0 is the latest tag. It matches PyPI 5.0.0 and is an ancestor of master, so python-semantic-release continues from it with its default v{version} tag format.

Testing

  • uv run --locked tox -e quality,docs,django52-drf314,django52-drflatest all pass locally. The two test envs run 48 tests each, the same as master. drf314 resolves DRF 3.14.0 and drflatest resolves 3.18.3. uv lock --check is clean.
  • The built wheel matches PyPI 5.0.0 file for file, except that the 7 test-package files (completion/tests, completion/api/tests, completion/api/v1/tests) no longer ship. completion/test_utils.py, which openedx-platform imports, still ships. The Requires-Dist set is identical. twine check passes, and the sdist still contains CHANGELOG.rst, README.rst and LICENSE.

Reviewer notes

  • The package stays in a flat layout (no src/ move) because openedx-translations depends on the completion/conf/locale path. Its transifex.yml uses source_file_dir: translations/completion/completion/conf/locale/en/, and its extraction workflow skips */src/*.
  • The tox envs are renamed py312-django52-drf{314,latest} → django52-drf{314,latest}. The py312 factor was never used, and CI already called the envs by the shorter names. The only required check is openedx/cla, and the CI job is still named Tests.
  • requires-python = ">=3.12" is new metadata. It matches the only Python classifier and the CI matrix.
  • The wheel tag changes from py2.py3 to py3, because the [wheel] universal = 1 setting is gone along with setup.cfg.

🤖 Generated with Claude Code

irfanuddinahmad and others added 3 commits October 15, 2026 15:43
Move setup.py/setup.cfg/.coveragerc metadata, isort and coverage config
into pyproject.toml (PEP 621/639) with setuptools-scm versioning, and read
__version__ from installed package metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace requirements/*.in/*.txt with PEP 735 dependency groups and
uv.lock. The tox DRF matrix (drf314/drflatest) now maps to the drf314 and
test groups, declared as [tool.uv] conflicts so each resolves separately.
Django and other global caps come from edx-lint via
`edx_lint write_uv_constraints` instead of downloading
common_constraints.txt in the Makefile. CI installs with setup-uv and runs
tox through uv, and also runs the existing docs tox env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add release.yml based on openedx/sample-plugin's release workflow: it runs
CI, lets python-semantic-release tag and build, creates the GitHub release
with the distributions attached, and publishes to PyPI via trusted
publishing. Remove the token-based pypi-publish.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 Oct 15, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

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

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.

…igrations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml Outdated
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
run: uv run --locked tox

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we can avoid --locked with uv run, with uv sync its already there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread pyproject.toml Outdated
include-package-data = false

[tool.setuptools.dynamic]
readme = {file = ["README.rst", "CHANGELOG.rst"], content-type = "text/x-rst"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With the changelog turned off in release.yml, CHANGELOG.rst won't be updated anymore (it already stops at 4.8.0 while PyPI is at 5.0.0), but it's still appended to the PyPI description here. Can you drop it from readme and add a short note at the top of CHANGELOG.rst pointing to GitHub Releases?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, dropped it from readme and added a note at the top of CHANGELOG.rst pointing to GitHub Releases.

Comment thread Makefile
Comment on lines -23 to -24
install:
pip install -r requirements/dev.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The install target was removed here and the README now points to make requirements. We'd rather not drop existing Makefile targets in these migrations, since someone's local workflow or a script may still call them. Can we keep it implemented with the uv equivalent instead?

install: ## install development environment requirements
	uv sync --locked --group dev

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored, using uv sync --group dev.

CHANGELOG.rst is no longer updated now that release notes go to GitHub
Releases, so stop appending it to the long description and note that at
the top of the file. uv sync --locked already guards the lockfile in CI.
Restore the install target, using uv sync --group dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread MANIFEST.in
include README.rst
include requirements/base.in
include requirements/test.in
recursive-include completion *.html *.png *.gif *js *.css *jpg *jpeg *svg *py

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The sdist grew from 60 files in 5.0.0 to 100 here. setuptools-scm adds every git-tracked file, so it now ships uv.lock, .github/, docs/, Makefile, tox.ini, pytest.ini, pylintrc, codecov.yml, catalog-info.yaml and more. Can you add excludes here?

prune .github
prune .tx
prune docs
prune htmlcov
exclude uv.lock Makefile tox.ini pytest.ini pylintrc pylintrc_tweaks codecov.yml catalog-info.yaml openedx.yaml manage.py .gitignore
global-exclude .coverage coverage.xml

# the checks that were required to merge -- and picks up any package added to
# ci.yml later without needing a change here.
run_ci:
uses: ./.github/workflows/ci.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

run_ci calls ci.yml without secrets: inherit, so on master pushes the Codecov step runs without CODECOV_TOKEN, and it has fail_ci_if_error: true. sample-plugin and XBlock are set up the same way, so tokenless upload is probably fine, but has this been confirmed? If the upload fails, release won't run.

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.

3 participants