Modernize Python repo: pyproject.toml + uv + semantic-release#251
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the pull request, @salman2013! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0b62620 to
767f8d9
Compare
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>
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>
|
@salman2013 Thanks for creating the PR! I am sharing a review which is done with the help of Claude, please address if you agree:
Below are the gaps in PR #251 relative to the standardized 1.
|
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>
There was a problem hiding this comment.
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.cfgintopyproject.toml(PEP 621) withsetuptools-scm. - Replace
pip-tools/requirements/*.txtwithuvdependency groups + updatedtox.iniand 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.
- Rename CI matrix job name to matrix.toxenv for clearer failure identification - Expand ruff lint rules (B, C4, UP, DJ) with inline comments - Add E501 ignore, isort known-third-party, and formatter indent-style - Move coverage config to include omit patterns, exclude_lines, and show_missing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Limit GITHUB_TOKEN to contents: read for the CI job to follow least-privilege principle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks @salman2013 — the big items from the last round are all done. One small thing remains: CI — redundant
|
astral-sh/setup-uv handles Python installation via python-version param. Removed separate actions/setup-python step and added enable-cache: true to setup-uv, matching xblocks-extra standard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-fixed 85 violations (f-strings, dict literals, deprecated builtins, etc.) and manually fixed 25 more (raise...from None in except blocks, noqa suppressions for pre-existing B017/B018/B008/B026 patterns, loop variable shadowing rename). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove request.body and oauth_headers from log.error() calls to prevent clear-text logging of sensitive OAuth data (CodeQL: py/clear-text-logging-sensitive-data). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Written with the assistance of Claude Code, human-reviewed before posting. Test Results: Modernize Python repoTested locally on ❌ Failures (must fix before merging)1 — Hardcoded
2 — Invented The original
|
f070339 to
6c47d7e
Compare
- Remove hardcoded __version__ from __init__.py (stale with setuptools-scm) - Update docs/conf.py to use importlib.metadata instead of reading __version__ - Remove invented fail_under = 70 coverage threshold (none existed before) - Add exclude_package_data to prevent test files from being included in wheel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Setuptools requires [tool.setuptools.exclude-package-data] (hyphen), not [tool.setuptools.exclude_package_data] (underscore), per its pyproject.toml schema. The underscore variant caused a build failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@farhan Could you please take a look at PR again. |
…conflicts Merge origin/main (automated requirements upgrade #277) into branch. Resolved modify/delete conflicts by keeping branch deletions of requirements/*.txt — these files were intentionally removed as part of migrating dependency management from pip-tools to uv. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
farhan
left a comment
There was a problem hiding this comment.
Ran full local verification (quality + docs + django42 + django52 — 841 tests pass on both Django versions). One blocker to address before merge, see inline.
…requirement OIDC requires pre-configuring a trusted publisher on pypi.org before it can work. Without that setup, the publish step would fail after PSR tags and bumps the version, leaving a dangling tag with no package on PyPI. Reverts to PYPI_UPLOAD_TOKEN secret auth, matching the existing pypi-publish.yml on main. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
farhan
left a comment
There was a problem hiding this comment.
LGTM!
Some manual testing of blocks before merging will be great.
Summary
Modernizes the Python tooling for
xblocks-contribin three phases, aligning with the Open edX org standard established inopenedx/sample-plugin.Ticket: openedx/public-engineering#506
Commits
chore: migrate package metadata to pyproject.tomlpyproject.toml(PEP 621) with staticdependencieslist anddynamic = ["version"]setuptools-scm(version_scheme = "only-version",local_scheme = "no-local-version")license = "AGPL-3.0"+license-files = ["LICENSE.txt"]setup.pyandsetup.cfgchore: switch dependency management from pip-tools to uv[dependency-groups](PEP 735):test-base,test(Django 5.2),django42,quality,doc,ci,dev[tool.uv].conflictsto allow Django 4.2 and 5.2 to coexist in a singleuv.lockwith separate resolutions[tool.edx_lint].uv_constraintsholds repo-specific pins;[tool.uv].constraint-dependenciesmanaged byedx_lint write_uv_constraintstox.inito usetox-uv>=1anduv-venv-lock-runnerwithdependency_groupsMakefile:upgraderunsuv lock --upgrade,requirementsrunsuv sync --group devpython-tests.yml: addedastral-sh/setup-uv,uv sync --group ci,uv run toxrequirements/directory (11 files)chore: add python-semantic-release and commitlint workflows[tool.semantic_release]withbuild_commandexportingSETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSIONbeforeuv buildrelease.yml: runspython-tests.ymlas a reusable workflow, then PSR v10.5.3 onmain, publishes to PyPI via OIDC trusted publisher (no token needed)commitlint.yml: enforces conventional commit format on PRspypi-publish.yml(was causing duplicate publishes)upgrade-python-requirements.ymlto sharedopenedx/.githubreusable workflowREADME.rstwith uv-based setup instructionsTest plan
make requirementsuv run tox -e django42uv run tox -e django52uv run tox -e docs