Repository navigation
Modernize Python tooling (uv, pyproject.toml, src layout, semantic release) - #246
salman2013 wants to merge 10 commits into
Conversation
- Add pyproject.toml with PEP 621 metadata, setuptools-scm dynamic versioning, coverage config, isort config, and semantic-release changelog config - Add .. changelog-insertion-marker to CHANGELOG.rst for PSR - Remove __version__ from __init__.py (unused at runtime) - Update docs/conf.py to use importlib.metadata for version - Delete setup.py, setup.cfg, and .coveragerc Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add dependency-groups (test-base/test/django42/quality/doc/ci/dev) - Add uv.lock (94 packages resolved) - Add constraint-dependencies via edx_lint write_uv_constraints - Rewrite tox.ini to use tox-uv>=1 and uv-venv-lock-runner - Rewrite Makefile to use uv run tox and uv sync - Rewrite ci.yml: setup-uv, uv sync --group ci, uv run tox, workflow_call trigger, matrix job name - Delete requirements/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add release.yml: runs CI via workflow_call, PSR v10.5.3, uploads dist artifact, publishes to PyPI via OIDC trusted publisher - Delete pypi-publish.yml (replaced by release.yml) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move code_annotations/ to src/code_annotations/ - Add where = ["src"] to [tool.setuptools.packages.find] - Update tox.ini quality commands to src/code_annotations paths - Update docs/conf.py sphinx-apidoc path to src/code_annotations - Update coverage omit path in pyproject.toml - Rewrite Makefile to use direct uv run --group commands (no tox) - Regenerate uv.lock 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>
requirements/doc.txt was removed in the uv migration, so RTD builds were failing. Switch to installing via uv export and pip install. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
irfanuddinahmad
left a comment
There was a problem hiding this comment.
Verified against actual current file content, live CI, and by actually running commands locally against this branch -- not just reading the diff. All CI checks are green, which is expected since the bugs below aren't caught by CI.
Same changelog: "false" bug as edx-lint#563 and api-doc-tools#409 -- identical release.yml pattern across all three, looks template-derived rather than repo-specific.
What's done correctly here and worth not re-litigating: license/SPDX handling (confirmed via an actual local build that it doesn't raise InvalidConfigError), the Django version-matrix uses the correct [tool.uv].conflicts pattern, isort is both declared and actually wired into the quality targets (unlike a sibling repo), no ruff scope-creep, and the OIDC publish + pre-flight tag/PyPI version check both check out.
| with: | ||
| git_committer_name: "github-actions" | ||
| git_committer_email: "github-actions@github.com" | ||
| changelog: "false" |
There was a problem hiding this comment.
changelog: "false" overrides the [tool.semantic_release.changelog] config this same PR carefully builds in pyproject.toml (mode = "update", matching insertion_flag) -- the action-level flag wins, silently disabling changelog generation entirely despite the config looking correct. This is the exact incident class that already caused real CHANGELOG.rst content loss in a sibling repo in this effort.
There was a problem hiding this comment.
Fixed in 4b04932 — removed changelog: "false" so the [tool.semantic_release.changelog] config in pyproject.toml now applies (the .. changelog-insertion-marker is present in CHANGELOG.rst).
| {include-group = "ci"}, | ||
| ] | ||
|
|
||
| [tool.uv] |
There was a problem hiding this comment.
Missing default-groups = []. I reproduced this directly against the PR branch:
$ uv run --group django42 python -Wd -m pytest --collect-only -q
error: Groups `dev` (enabled by default) and `django42` are incompatible with the conflicts: {`code-annotations:dev`, `code-annotations:django42`}
This is make test-all's first line (Makefile), so that target is broken today for anyone running it locally. CI stays green only because tox-uv happens to pass --no-default-groups internally when driving tests through tox -- it masks the gap rather than avoiding it. uv.lock's own [manifest].conflicts list independently corroborates this: it enumerates django42 vs. test, doc, quality, and dev.
There was a problem hiding this comment.
Fixed in 4b04932 — added default-groups = [] under [tool.uv]. Every uv invocation in the Makefile and CI already names its group explicitly, so nothing depended on the default dev group. Verified uv run --group django42 python -Wd -m pytest now runs (94 passed).
| pull_request: | ||
| branches: | ||
| - "**" | ||
| workflow_call: |
There was a problem hiding this comment.
This new workflow_call: trigger, combined with the pre-existing push: [master] trigger a few lines up (unchanged by this PR), means every push to master now runs this full matrix twice concurrently: once via the direct push trigger, once via release.yml calling this workflow as its run_tests job. Recommend dropping the push: [master] trigger now that release.yml owns that path.
There was a problem hiding this comment.
Fixed in 4b04932 — dropped the push: [master] trigger; release.yml now owns the master path via workflow_call, and pull_request still triggers CI directly.
|
One more, on a file this PR doesn't touch so I can't anchor it inline: Line 1 references a file this PR deletes ( |
…tooling # Conflicts: # requirements/base.txt # requirements/ci.txt # requirements/common_constraints.txt # requirements/dev.txt # requirements/django.txt # requirements/doc.txt # requirements/pip-tools.txt # requirements/pip.txt # requirements/quality.txt # requirements/test.txt
…tooling # Conflicts: # .github/workflows/ci.yml # .github/workflows/pypi-publish.yml # requirements/ci.txt # requirements/common_constraints.txt # requirements/dev.txt # requirements/django.txt # requirements/doc.txt # requirements/pip.txt # requirements/quality.txt # requirements/test.txt
- release.yml: drop `changelog: "false"` so the semantic-release changelog config in pyproject.toml takes effect - pyproject.toml: set `default-groups = []` so `uv run --group django42` no longer conflicts with the default `dev` group (fixes `make test-all`) - ci.yml: drop the push-to-master trigger; release.yml already runs CI via workflow_call, so master pushes ran the matrix twice - MANIFEST.in: remove stale requirements/base.in reference and point recursive-include at src/code_annotations Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@irfanuddinahmad re: |
irfanuddinahmad
left a comment
There was a problem hiding this comment.
Sorry, my August comments here are out of date: this PR missed the round edx-lint#563 and api-doc-tools#409 got in October, so some of today's fixes need to be reversed. This replaces my earlier changelog comment.
- Please put back
changelog: "false"and remove the[tool.semantic_release.changelog]and[tool.semantic_release.changelog.default_templates]tables (and the CHANGELOG insertion marker). - Please re-sync
release.ymlwith sample-plugin's current file, the same as edx-lint#563: PSR v10.7.0,gh release createwith the dists attached, adistribution-artifactsartifact withpath: distandid: artifact-download, every action SHA-pinned (pypi-publish too, no@release/v1),git_committer_email: "actions@users.noreply.github.com", and the comment blocks. - Please reseed
uv.lockfrom master'srequirements/*.txtpins instead of a fresh resolve: runedx_lint write_uv_constraints pyproject.toml, add master's pins asname==vertoconstraint-dependencies,uv lock, restore pyproject,uv lockagain, then diffuv export --only-group <g>against eachrequirements/<g>.txt. The current lock is behind master, e.g. edx-lint 6.2.0 → 5.2.0, python-slugify 9.1.3 → 8.0.4, pylint 4.1.3 → 4.0.6. Please also drop theedx-lint<6andsetuptools<81caps fromquality. ci.yml: please useuv sync --locked --group cianduv run --locked tox ..., and addpermissions: contents: readto the job.- Makefile: please drop the
uv run --group ...prefix from every target and call the tools bare (requirementskeepsuv sync);upgradeshould beuv run --with edx-lint edx_lint write_uv_constraints pyproject.tomlthenuv lock --upgrade. Please also keepquality,docsandtest-allcalling tox as on master. - Please keep
__version__insrc/code_annotations/__init__.py:from importlib.metadata import versionand__version__ = version("code-annotations"). - Please make
dependenciesmatch PyPI 3.0.0: plainclick,pyyaml,Jinja2,stevedore,python-slugify. - Release settings, inline.
nits: rerun edx_lint write_uv_constraints (the social-auth pins are missing), and point the README CI badge at actions/workflows/release.yml/badge.svg?branch=master, since ci.yml no longer runs on master.
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.12", | ||
| ] | ||
| dependencies = [ |
There was a problem hiding this comment.
Please restore PyPI 3.0.0's requirements: no version floors.
| [tool.setuptools_scm] | ||
| version_scheme = "only-version" | ||
| local_scheme = "no-local-version" | ||
| fallback_version = "0.0.0.dev0" |
There was a problem hiding this comment.
Please use fallback_version = "0.0.0".
| "contrib/config/*.yaml", | ||
| ] | ||
|
|
||
| [tool.semantic_release] |
There was a problem hiding this comment.
Please add tag_format = "v{version}" here.
| major_on_zero = false | ||
| allow_zero_version = true | ||
|
|
||
| [tool.semantic_release.changelog] |
There was a problem hiding this comment.
Please remove this and the default_templates table; release.yml should run PSR with changelog: "false".
| django42 = [{include-group = "test-base"}, "Django>=4.2,<4.3"] | ||
| quality = [ | ||
| {include-group = "test"}, | ||
| "edx-lint<6", |
There was a problem hiding this comment.
Please drop <6; master is on edx-lint 6.2.0.
| "isort", | ||
| "pycodestyle", | ||
| "pydocstyle", | ||
| "setuptools<81", |
There was a problem hiding this comment.
Please drop this cap; it isn't on master.
| - name: Install Dependencies | ||
| run: pip install -r requirements/ci.txt | ||
| - name: Install CI dependencies | ||
| run: uv sync --group ci |
There was a problem hiding this comment.
uv sync --locked --group ci
| env: | ||
| TOXENV: ${{ matrix.toxenv }} | ||
| run: tox | ||
| run: uv run tox -e ${{ matrix.toxenv }} |
There was a problem hiding this comment.
uv run --locked tox -e ${{ matrix.toxenv }}
| @@ -0,0 +1,55 @@ | |||
| name: Semantic Release | |||
There was a problem hiding this comment.
Please replace this with sample-plugin's current release.yml (see the review summary).
| @@ -1,5 +1,3 @@ | |||
| """ | |||
| Extensible tools for parsing annotations in codebases. | |||
| """ | |||
There was a problem hiding this comment.
Please add from importlib.metadata import version and __version__ = version("code-annotations").
- release.yml: re-sync with sample-plugin (PSR v10.7.0, changelog off,
gh release create with dists attached, SHA-pinned actions)
- ci.yml: use --locked for sync/run and add contents: read permission
- Makefile: call tools bare; quality/docs/test-all go through tox
- pyproject: unpinned runtime deps matching 3.0.0, fallback_version
0.0.0, tag_format v{version}, drop PSR changelog tables and the
edx-lint/setuptools caps, regenerate uv constraints
- uv.lock: reseed from master's requirements/*.txt pins
- restore __version__ via importlib.metadata
- drop the CHANGELOG insertion marker
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
irfanuddinahmad
left a comment
There was a problem hiding this comment.
Thanks, all addressed.
nit: dev, doc and quality lock Django 5.2.19, master pins 5.2.18; uv lock --upgrade-package django==5.2.18 brings it back.
Summary
pyproject.toml(PEP 621/639):setuptools-scmdynamic versioning,importlib.metadatafor docs version, coverage + isort config, semantic-release changelog config. Deletesetup.py,setup.cfg,.coveragerc.uv:dependency-groups(test-base/test/django42/quality/doc/ci/dev),uv.lock, rewritetox.iniwithtox-uv>=1/uv-venv-lock-runner, rewriteMakefilewith directuv run --groupcommands, update CI toastral-sh/setup-uvwithworkflow_calltrigger. Deleterequirements/.python-semantic-releaseworkflow:release.ymlruns CI, cuts releases via PSR v10.5.3, publishes to PyPI via OIDC trusted publisher. Deletepypi-publish.yml.src/layout:git mv code_annotations/ src/code_annotations/, update all filesystem paths intox.ini,docs/conf.py,pyproject.toml,Makefile.Ticket: openedx/public-engineering#519
Test plan
release.ymlbefore merging🤖 Generated with Claude Code