Repository navigation
Modernize Python tooling (pyproject.toml, uv, python-semantic-release) - #328
salman2013 wants to merge 4 commits into
Conversation
Replace setup.py/setup.cfg/.coveragerc with a PEP 621 pyproject.toml, using setuptools-scm for the version and an SPDX license expression. The built wheel's file list matches the one built from setup.py. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Move requirements/*.in into PEP 735 dependency groups, lock them in uv.lock (seeded from the existing requirements/*.txt pins, so no versions change), and run tox and CI through tox-uv and setup-uv. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Replace the tag-triggered pypi-publish.yml with release.yml, adapted from openedx/sample-plugin: merges to master are versioned from their conventional commits, released on GitHub with the dists attached, and published to PyPI through trusted publishing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks for the pull request, @salman2013! This repository is currently unmaintained. 🔘 Find a technical reviewerTo get help with finding a technical reviewer, reach out to the community contributions project manager for this PR:
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. |
| on: | ||
| push: | ||
| branches: [master] | ||
| # Run manually on an older branch to cut a patch release for that line. |
There was a problem hiding this comment.
Adding it seems fine to me.
But have we decided to add it in the PR's. As per current understanding it's only a timely needed feature.
There was a problem hiding this comment.
I've kept it. It mirrors the current release.yml on openedx/sample-plugin, which added the workflow_dispatch force input, the "fail a manual run that released nothing" check, and the release/* maintenance branch group together. With all three in place, a manual run can cut a patch release from a release branch, and a manual run that releases nothing fails instead of showing green. Happy to drop all three together if we decide it shouldn't be in these PRs yet.
| recursive-include src/cc2olx/templates * | ||
| recursive-include requirements * | ||
| recursive-include tests * | ||
| prune test_data |
There was a problem hiding this comment.
The sdist now picks up every tracked file (uv.lock, .github/, Dockerfile, etc.; 309 KB → 366 KB). Exclude them?
MANIFEST.in:6
| prune test_data | |
| prune test_data | |
| prune .github | |
| exclude uv.lock Dockerfile .dockerignore .editorconfig .gitignore codecov.yml |
Also, openedx.yaml is legacy, can we delete it?
There was a problem hiding this comment.
Done in 5bcce58, using your excludes as written. The sdist is back to 310 KB. Compared with master's sdist, the only files that dropped out are setup.py and requirements/, both deleted on purpose. I've left openedx.yaml alone here because it isn't part of the tooling migration, so it fits better in its own PR.
| # Let tox control the Django version for tests | ||
| sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp | ||
| mv requirements/test.tmp requirements/test.txt | ||
| pip install . |
There was a problem hiding this comment.
uv venvs have no pip, so this uses whatever pip is on PATH (or fails).
Makefile:80
| pip install . | |
| uv pip install . |
| [tool.setuptools_scm] | ||
| version_scheme = "only-version" | ||
| local_scheme = "no-local-version" | ||
| fallback_version = "0.0.0" |
There was a problem hiding this comment.
Docker builds now report 0.0.0 (.git is in .dockerignore, so setuptools-scm falls back). Master's image reported 0.4.0.
Dockerfile:2
ARG VERSION=0.0.0
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CC2OLX=$VERSIONdocker build --build-arg VERSION=0.4.0 -t cc2olx .
There was a problem hiding this comment.
Done in 5bcce58. I also updated the README's docker build example to pass --build-arg VERSION=<VERSION>. Checked locally: with VERSION=0.4.0 the image's cc2olx.__version__ is 0.4.0, and without the build arg it's 0.0.0.
| pull_request: | ||
| branches: | ||
| - '**' | ||
| workflow_call: |
There was a problem hiding this comment.
With workflow_call from release.yml, the push: trigger makes CI run twice on every merge. Same fix as openedx/forum#293:
.github/workflows/ci.yml:3
on:
pull_request:
branches:
- '**'
workflow_call:and point the badge at release.yml:
README.rst:4
.. image:: https://github.com/openedx/cc2olx/actions/workflows/release.yml/badge.svg?branch=master
:target: https://github.com/openedx/cc2olx/actions/workflows/release.ymlThere was a problem hiding this comment.
Done in 5bcce58: dropped push: and pointed the badge at release.yml. The live sample-plugin ci.yml also has only pull_request and workflow_call now.
| requirements: ## install development environment requirements | ||
| pip install -qr requirements/pip-tools.txt | ||
| pip-sync requirements/dev.txt requirements/private.* | ||
| uv sync --group dev |
There was a problem hiding this comment.
nit: fail instead of silently rewriting uv.lock.
Makefile:87
| uv sync --group dev | |
| uv sync --locked --group dev |
| name = "cc2olx" | ||
| dynamic = ["version"] | ||
| description = "Command line tool, that converts Common Cartridge courses to Open edX Studio imports." | ||
| readme = "README.rst" |
There was a problem hiding this comment.
nit: other modernized openedx repos set this.
pyproject.toml:9
| readme = "README.rst" | |
| readme = "README.rst" | |
| authors = [ | |
| {name = "Open edX Project", email = "[email protected]"}, | |
| ] |
| [pytest] | ||
| DJANGO_SETTINGS_MODULE = test_settings | ||
| norecursedirs = .* requirements |
There was a problem hiding this comment.
nit: dead config, pytest.ini wins (WARNING: ignoring pytest config in tox.ini!), and requirements no longer exists.
tox.ini:5-7
| [pytest] | |
| DJANGO_SETTINGS_MODULE = test_settings | |
| norecursedirs = .* requirements |
There was a problem hiding this comment.
Removed in 5bcce58. Tests still collect and pass, 169 as before.
- Run CI only on pull requests and from release.yml, so a merge to master doesn't run it twice; point the README badge at release.yml. - Exclude repo-only files from the sdist. - Let the Docker build pass the version to setuptools-scm. - Use uv pip and uv sync --locked in the Makefile. - Set authors and drop the dead [pytest] section from tox.ini. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Description
Migrates cc2olx from setup.py/pip-tools to
pyproject.toml, uv, and python-semantic-release, following openedx/sample-plugin. The package was already insrc/layout, so no code moves.Changes (one commit per step)
1. Metadata →
pyproject.toml(PEP 621)setup.py,setup.cfgand.coveragercwithpyproject.toml.__version__is kept and read throughimportlib.metadata.license = "AGPL-3.0-only", matching the old "AGPL v3" classifier (no "or later").include-package-data = false, withtemplates/**listed. Otherwise setuptools-scm would addtools/README.rstto the wheel.MANIFEST.innow hasprune test_data. Otherwise setuptools-scm would add the.imsccfixtures to the sdist (309 KB → 10 MB).:ref:role, which failstwine checkonmaster. PyPI rejects descriptions that don't render.CHANGELOG.rsthas a deprecation note; release notes are now on GitHub Releases.2. pip-tools → uv
requirements/is replaced by PEP 735 dependency groups anduv.lock.uv.lockwas seeded frommaster'srequirements/*.txtpins, so no installed versions change.make upgradetakes upgrades from here on.tox-uvwithuv-venv-lock-runner. CI usessetup-uvand--locked.3. python-semantic-release
release.ymlis adapted from sample-plugin's and replacespypi-publish.yml. Merges tomasterare versioned from conventional commits, released on GitHub with the dists attached, and published to PyPI via trusted publishing (OIDC).PYPI_UPLOAD_TOKENis no longer used.Maintainer actions needed before merge
v0.4.0tag. The existing tags are bare (0.4.0), and PSR usesv{version}. Without the tag, PSR computes 0.1.0 as the next release.cc2olx, repoopenedx/cc2olx, workflowrelease.yml. The package has never been published, because the 0.4.0pypi-publish.ymlrun failed.Ticket: Ticket: openedx/public-engineering#519
🤖 Generated with Claude Code