Skip to content

Modernize Python repo: pyproject.toml + uv + semantic-release#251

Open
salman2013 wants to merge 8 commits into
mainfrom
salman/modernize-branch
Open

Modernize Python repo: pyproject.toml + uv + semantic-release#251
salman2013 wants to merge 8 commits into
mainfrom
salman/modernize-branch

Conversation

@salman2013

@salman2013 salman2013 commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Modernizes the Python tooling for xblocks-contrib in three phases, aligning with the Open edX org standard established in openedx/sample-plugin.

Ticket: openedx/public-engineering#506

Changes generated by Claude Sonnet 4.6 using the modernize-python-tooling skill, reviewed by Salman.


Commits

chore: migrate package metadata to pyproject.toml

  • Consolidated all package metadata into pyproject.toml (PEP 621) with static dependencies list and dynamic = ["version"]
  • Configured setuptools-scm (version_scheme = "only-version", local_scheme = "no-local-version")
  • Updated license to SPDX string format (PEP 639): license = "AGPL-3.0" + license-files = ["LICENSE.txt"]
  • Deleted setup.py and setup.cfg

chore: switch dependency management from pip-tools to uv

  • Added [dependency-groups] (PEP 735): test-base, test (Django 5.2), django42, quality, doc, ci, dev
  • Used [tool.uv].conflicts to allow Django 4.2 and 5.2 to coexist in a single uv.lock with separate resolutions
  • [tool.edx_lint].uv_constraints holds repo-specific pins; [tool.uv].constraint-dependencies managed by edx_lint write_uv_constraints
  • Rewrote tox.ini to use tox-uv>=1 and uv-venv-lock-runner with dependency_groups
  • Updated Makefile: upgrade runs uv lock --upgrade, requirements runs uv sync --group dev
  • Updated python-tests.yml: added astral-sh/setup-uv, uv sync --group ci, uv run tox
  • Deleted entire requirements/ directory (11 files)

chore: add python-semantic-release and commitlint workflows

  • Added [tool.semantic_release] with build_command exporting SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION before uv build
  • Added release.yml: runs python-tests.yml as a reusable workflow, then PSR v10.5.3 on main, publishes to PyPI via OIDC trusted publisher (no token needed)
  • Added commitlint.yml: enforces conventional commit format on PRs
  • Deleted pypi-publish.yml (was causing duplicate publishes)
  • Reverted upgrade-python-requirements.yml to shared openedx/.github reusable workflow
  • Updated README.rst with uv-based setup instructions

Test plan

  • make requirements
  • uv run tox -e django42
  • uv run tox -e django52
  • uv run tox -e docs

salman2013 and others added 2 commits May 18, 2026 23:50
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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 May 18, 2026
@openedx-webhooks

openedx-webhooks commented May 18, 2026

Copy link
Copy Markdown

Thanks for the pull request, @salman2013!

This repository is currently maintained by @openedx/axim-engineering.

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.

Comment thread .github/workflows/release.yml Dismissed
@salman2013 salman2013 changed the title Salman/modernize branch Modernize Python repos: pyproject.toml + uv + semantic-release May 18, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013 salman2013 force-pushed the salman/modernize-branch branch from 0b62620 to 767f8d9 Compare May 18, 2026 19:20
@salman2013 salman2013 changed the title Modernize Python repos: pyproject.toml + uv + semantic-release Modernize Python repo: pyproject.toml + uv + semantic-release May 18, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions May 20, 2026
Resolved conflicts by keeping deletions of requirements/*.txt and
.github/workflows/pypi-publish.yml, which were intentionally removed
as part of the pip-tools → uv migration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013 salman2013 marked this pull request as ready for review June 3, 2026 19:38
Resolved conflicts by keeping requirements/*.txt deletions from modernize-branch
(migrated to pyproject.toml/uv). Includes codecov-action bump to v6.0.2 from main.

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

farhan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@salman2013 Thanks for creating the PR!

I am sharing a review which is done with the help of Claude, please address if you agree:

Consider the standard repo as xblocks-extra after merging of openedx/xblocks-extra#50 and openedx/xblocks-extra#38.

Below are the gaps in PR #251 relative to the standardized xblocks-extra (main + PR 50 + PR 38).


1. pyproject.toml

2. MANIFEST.in

  • CHANGELOG.rst must go. PR 50 deletes CHANGELOG.rst (semantic-release with changelog: "false" → GitHub Releases are the changelog). PR Modernize Python repo: pyproject.toml + uv + semantic-release #251 still ships CHANGELOG.rst in the repo and include CHANGELOG.rst in MANIFEST.in — both should be removed.
  • Philosophy differs. The standard is exclusion-based (prune .github/docs/tests, exclude dev files) with package data declared in pyproject's [tool.setuptools.package-data]. PR Modernize Python repo: pyproject.toml + uv + semantic-release #251 is inclusion-based (recursive-include per file extension) with manual deep-path prunes. Aligning means moving the asset globs into [tool.setuptools.package-data] and slimming MANIFEST.in down to exclusions.
  • include LICENSE.txt is redundant — already covered by license-files in pyproject.

3. tox.ini

4. release.yml

5. CI workflow

6. Makefile

Repo-level stragglers in PR #251

  • Delete CHANGELOG.rst, .coveragerc, and (after ruff migration) pylintrc / pylintrc_tweaks.
  • Standard repo has a .python-version file; xblocks-core has none.

Top 3 by impact:

  1. ruff migration replacing the pylint/pycodestyle/pydocstyle/isort stack
  2. CHANGELOG.rst removal to match the semantic-release flow
  3. Deciding tox-in-CI vs direct-uv-in-CI — that one goes the other direction and may mean updating the xblocks-extra standard instead

🤖 Generated with Claude Code

salman2013 and others added 3 commits June 22, 2026 22:24
PSR's action environment does not have uv available, so uv build fails.
Switch to python -m build (installing it via pip) and remove the now-
unnecessary setup-uv step from release.yml.

Ref: openedx/XBlock#928

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace pylint/pycodestyle/pydocstyle/isort with ruff (E, F, I, W rules)
- Remove CHANGELOG.rst (semantic-release uses GitHub Releases)
- Move coverage config from .coveragerc into pyproject.toml
- Add Django classifiers and pin setuptools-scm>=8.0
- Add lint/format/test/docs Makefile targets delegating to tox
- SHA-pin all GitHub Actions in release.yml
- Add push-to-main trigger and set fail-fast: false in python-tests.yml
- Delete pylintrc, pylintrc_tweaks, .coveragerc, CHANGELOG.rst

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Modernizes the repo’s Python packaging/tooling by moving metadata/config into pyproject.toml, switching dependency management to uv, and introducing automated releases via python-semantic-release (plus commit message linting).

Changes:

  • Migrate packaging metadata/config from setup.py/setup.cfg into pyproject.toml (PEP 621) with setuptools-scm.
  • Replace pip-tools/requirements/*.txt with uv dependency groups + updated tox.ini and Make targets.
  • Add GitHub Actions workflows for semantic-release publishing and commitlint; update Python CI to use uv.

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml New canonical packaging + tool configuration; defines dependency groups for uv/tox.
tox.ini Switch tox to tox-uv with uv-venv-lock-runner and dependency groups.
Makefile Replace pip-tools workflow with uv-based install/upgrade and new lint/test/docs targets.
README.rst Update documentation for uv-based setup and adjust project status wording.
.github/workflows/python-tests.yml Update CI to install dependencies with uv and run tox via uv run.
.github/workflows/release.yml Add semantic-release-based GitHub Release + PyPI publish via OIDC.
.github/workflows/commitlint.yml Add Conventional Commits enforcement via reusable workflow.
MANIFEST.in Adjust packaged root files after metadata migration/removals.
setup.py Removed legacy setuptools metadata and pip-tools requirement loading.
setup.cfg Removed legacy tool configuration (isort/wheel).
requirements/* Removed pip-tools compiled requirements and constraints files in favor of uv.
pylintrc / pylintrc_tweaks Removed pylint configuration (quality now via ruff).
.github/workflows/pypi-publish.yml Removed legacy PyPI publish workflow (superseded by release workflow).
.coveragerc Removed in favor of coverage config in pyproject.toml.
CHANGELOG.rst Removed legacy changelog file (semantic-release configured without changelog generation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.rst
* In Development: We're building and testing this block.
* Ready to Use: You can try this on your site using the Waffle flag.
* Done: The built-in block has been removed. The setup.py entrypoint has been removed from edx-platform and added to xblock-contrib.
* Done: The built-in block has been removed. The ``pyproject.toml`` entry-point has been removed from edx-platform and added to xblock-contrib.
Comment thread pyproject.toml
"beautifulsoup4",
"chem",
"defusedxml",
"django",
Comment on lines +8 to +10
run_tests:
uses: ./.github/workflows/python-tests.yml

Comment thread Makefile
Comment on lines +16 to +35
lint: ## run linting checks
tox -e quality

format: ## auto-fix ruff lint and formatting issues
uv run ruff check --fix .
uv run ruff format .

test: ## run tests against all supported Python/Django combinations
tox -e "py312-django{42,52}"

docs: ## build documentation
tox -e docs

upgrade: ## update uv.lock and regenerate uv constraints from edx-lint
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

requirements: ## install development environment requirements using uv
uv sync --group dev
uv tool install tox --with tox-uv
Comment on lines +31 to +33
- name: Install uv
uses: astral-sh/setup-uv@v6

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

small fixes to fully align with the xblocks-extra standard.

jobs:
python-tests:
name: Run Python Tests and Coverage
runs-on: ubuntu-latest

@farhan farhan Jun 24, 2026

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.

I think we should the tox env name so it's immediately clear which matrix job failed.

Suggested change
runs-on: ubuntu-latest
name: ${{ matrix.toxenv }}

Comment thread pyproject.toml

[tool.ruff.lint]
select = ["E", "F", "I", "W"]

@farhan farhan Jun 24, 2026

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.

I like the way how they are defined in the xblocks-extra, I think we should follow same tools and docs.

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: Waiting on Author

Development

Successfully merging this pull request may close these issues.

7 participants