Skip to content

Migrate to modern Python tooling (uv, pyproject.toml, semantic-release) - #2423

Open
salman2013 wants to merge 5 commits into
openedx:masterfrom
salman2013:modernize-python-tooling
Open

salman2013 wants to merge 5 commits into
openedx:masterfrom
salman2013:modernize-python-tooling

Conversation

@salman2013

@salman2013 salman2013 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Phase 1 — Consolidate all package metadata into `pyproject.toml` (PEP 621): static dependencies, SPDX license, setuptools-scm for dynamic versioning, coverage config, isort config; delete `setup.py`, `setup.cfg`, `.coveragerc`
  • Phase 2 — Replace pip-tools with uv: `[dependency-groups]` (PEP 735), `uv.lock`, updated `tox.ini` to use `tox-uv` + `uv-venv-lock-runner`, updated `Makefile` and CI workflow to use `uv sync`/`uv run tox`
  • Phase 3 — Add `python-semantic-release` for automated versioning and PyPI publishing via OIDC trusted publisher; delete legacy `pypi-publish.yml`
  • Phase 4 — Migrate to `src/` layout: move `openassessment/` → `src/openassessment/`, add `where = ["src"]` to `pyproject.toml`, update Makefile, scripts, MANIFEST.in, and karma.conf.js paths

Test plan

  • CI passes on this PR (`django42`, `django52`, `js`, `quality` environments)
  • Configure OIDC trusted publisher on PyPI for `openedx/edx-ora2` → workflow `release.yml` before merging

🤖 Generated with Claude Code

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 17, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @salman2013!

This repository is currently maintained by @openedx/openedx-unmaintained.

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 the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Jul 17, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.53%. Comparing base (b60672e) to head (51a0014).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2423      +/-   ##
==========================================
+ Coverage   95.46%   95.53%   +0.06%     
==========================================
  Files         198      198              
  Lines       22842    22820      -22     
  Branches     1551     1549       -2     
==========================================
- Hits        21807    21801       -6     
+ Misses        780      765      -15     
+ Partials      255      254       -1     
Flag Coverage Δ
unittests 95.53% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@salman2013
salman2013 force-pushed the modernize-python-tooling branch from d6b467b to 5ae0ab5 Compare July 20, 2026 11:45
@itsjeyd itsjeyd moved this from Needs Triage to Waiting on Author in Contributions Jul 28, 2026
@itsjeyd

itsjeyd commented Jul 28, 2026

Copy link
Copy Markdown

Hi @salman2013, thank you for your contribution! Please let us know when it is ready for review.

@salman2013 salman2013 changed the title chore: migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Sep 2, 2026
@salman2013
salman2013 force-pushed the modernize-python-tooling branch 3 times, most recently from 13c9e99 to 7d5e631 Compare September 2, 2026 08:52
Comment thread pyproject.toml
Comment thread pyproject.toml
readme = "README.rst"
license = "AGPL-3.0-only"
license-files = ["LICENSE"]
authors = [

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.

Same as acid-block#282: {name = "edX", email = "oscm@edx.org"} is the legacy convention. This migration effort has standardized on {name = "Open edX Project", email = "oscm@openedx.org"}, matching sample-plugin's actual current pyproject.toml.

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.

This one doesn't look addressed yet — pyproject.toml still has {name = "edX", email = "oscm@edx.org"}. Please update to {name = "Open edX Project", email = "oscm@openedx.org"} per the migration convention.

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.

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.

Confirmed — pyproject.toml now has {name = "Open edX Project", email = "oscm@openedx.org"}. Thanks for the fix. Resolving.

Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/ci.yml
@salman2013 salman2013 changed the title Migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Migrate to modern Python tooling (uv, pyproject.toml, semantic-release) Sep 8, 2026
@itsjeyd itsjeyd moved this from Waiting on Author to In Eng Review in Contributions Sep 15, 2026
@itsjeyd itsjeyd added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Sep 15, 2026
@itsjeyd

itsjeyd commented Sep 15, 2026

Copy link
Copy Markdown

Hi @salman2013, it looks like one of the coverage checks is failing here. Could you have a look?

…ntic-release)

- Migrate to src layout (src/openassessment/)
- Adopt uv for dependency management with pyproject.toml
- Add tox environments: docs, quality; update js env to django42
- Integrate python-semantic-release for automated versioning
- Update release workflow with immutable releases strategy and bumped action versions
- Fix i18n_tool, webpack, and eslint paths for src layout
- Update author to Open edX Project convention
- Add docs tox env with doc8, build, and twine checks
- Switch coverage to source_pkgs; add pragma: no cover to __version__

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013
salman2013 force-pushed the modernize-python-tooling branch from 030f813 to 199dc30 Compare September 17, 2026 11:16
salman2013 and others added 4 commits September 17, 2026 16:24
…tooling

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/pypi-publish.yml
#	openassessment/__init__.py
The omit pattern 'openassessment/runtime_imports/*' no longer matches
'src/openassessment/runtime_imports/*' after the src layout migration.
Use '*/runtime_imports/*' to match regardless of path prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change --cov target from 'openassessment' to 'src/openassessment' so
  pytest-cov finds the package after the src layout migration
- Add 'build' to norecursedirs to prevent stale build artifacts from
  being collected by pytest
- Remove */tests/*, */__pycache__/*, */settings.py from coverage omit
  to match original .coveragerc behaviour; omitting in-package test
  files (100% covered) was artificially lowering the project coverage %

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds lock entries for build, doc8, twine and their transitive
dependencies introduced in the doc dependency group.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013

Copy link
Copy Markdown
Contributor Author

@itsjeyd All tests are green now.

@itsjeyd

itsjeyd commented Sep 22, 2026

Copy link
Copy Markdown

Thanks @salman2013.

@openedx/axim-engineering Pinging you here since this repo is currently unmaintained.

This PR got approval from a CC earlier (#2423 (review)) and has a green build. Could you please have a look and merge the changes if they look good to you as well?

@itsjeyd itsjeyd added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Sep 22, 2026
Comment thread pyproject.toml

[tool.setuptools.package-data]
# locale/ is a symlink to conf/locale/ — include the real path instead
# (setuptools cannot copy symlinked directories into the wheel)

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.

python -m build --wheel fails on this branch:

error: can't copy 'src/openassessment/locale': doesn't exist or not a regular file

src/openassessment/locale is a git-tracked symlink to conf/locale, and setuptools-scm's file finder puts every git-tracked path into SOURCES.txt, so build_py tries to copy the symlink as a file. origin/master builds fine. PSR runs build_command before it commits or tags, so the first push to master after this merges fails there and no version publishes.

The comment here is wrong too. MANIFEST.in's recursive-include src/openassessment/locale *.mo does copy through the symlink: published 7.1.1 and a build off this branch both carry the same 77 .mo files under openassessment/locale/, so conf/locale/** only adds a second copy of them.

Comment thread pyproject.toml
[tool.setuptools.packages.find]
where = ["src"]
include = ["openassessment*"]
exclude = ["*.tests", "*.tests.*"]

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.

Once the build is fixed the wheel is 957 files / 4,878,011 bytes, against 466 / 2,601,590 for PyPI 7.1.1. Nothing that shipped before is dropped. What is new is 154 duplicate locale files under openassessment/conf/locale/, 191 test and spec files including 101 fixtures under openassessment/xblock/test/data, and the sass sources, xblock/static/xml and the font-awesome fonts.

include-package-data defaults to true under pyproject.toml, and with setuptools-scm's file finder that means every git-tracked file under a package directory, so neither MANIFEST.in nor [tool.setuptools.package-data] bounds the wheel any more. Widening this exclude to cover *.test is not enough on its own; I tried it and the files still ship as package data of the parent package.

Get the wheel back to what 7.1.1 shipped.

Comment thread .github/workflows/ci.yml
contents: read
strategy:
fail-fast: false
matrix:

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.

docs is in the tox envlist but not in this matrix, and it is red: tox -e docs stops at doc8 docs/ with 105 errors across 8 files. That env is the only place that runs python -m build --wheel and twine check, which is what would have caught the wheel not building.

Add docs to the matrix and fix the doc8 failures.

@@ -0,0 +1,121 @@
name: Semantic Release

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.

.github/release_process.md still says to bump the version in openassessment/__init__.py and package.json and then hand-create a matching release tag. That path no longer exists, the Python version comes from git tags now, and semantic-release creates the tag. Update it here.

@itsjeyd itsjeyd added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Sep 29, 2026
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 waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

5 participants