Skip to content

chore: Modernize codejail to use uv and pyproject.toml - #328

Open
farhan wants to merge 6 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo
Open

farhan wants to merge 6 commits into
openedx:masterfrom
farhan:farhan/modernize-python-repo

Conversation

@farhan

@farhan farhan commented Sep 14, 2026

Copy link
Copy Markdown

Important

PR implemented with the assistance of Claude Code. Refined and validated before being submitted for code review.

Modernize codejail
Part of openedx/public-engineering#517

Summary

  • edx-codejail on PyPI
  • Move the package into a src/ layout
  • Replace setup.py/setup.cfg with pyproject.toml (PEP 621 static metadata)
  • Switch from pip-compile to uv with PEP 735 dependency groups; commit uv.lock
  • Retain pylint/isort/pycodestyle as on master
  • Coverage config moved into pyproject.toml
  • Keep ci.yml in parity with master — all jobs (test matrix + quality) run inside the Docker/AppArmor container; only a workflow_call trigger is added so release.yml can reuse it
  • Add python-semantic-release + release.yml (OIDC trusted publishing), replacing the legacy pypi-release.yml
  • Add commitlint.yml was already present on master — retained as-is

Removed/Updated

Deleted files: setup.py, setup.cfg, requirements/, .coveragerc, .github/workflows/pypi-release.yml

Removed Makefile targets:

Target Reason
$(COMMON_CONSTRAINTS_TXT) (wget rule) pip-compile/constraints infrastructure removed; edx-lint constraints now managed via [tool.edx_lint].uv_constraints

Updated Makefile targets:

Target Change
upgrade Replaced pip-compile with uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml && uv lock --upgrade
requirements / dev-requirements Replaced pip install -r requirements/*.txt with uv sync --group dev
quality Updated path from codejail to src/codejail to reflect src/ layout move
isort Updated path from codejail to src/codejail to reflect src/ layout move
clean Updated path from codejail to src/codejail to reflect src/ layout move

Versioning

setuptools-scm with dynamic = ["version"] — master had a PyPI publish workflow; python-semantic-release controls the version string at release time via git tags.

Important Notes

  • No [testenv:docs] — codejail has no docs infrastructure (no docs/ directory, no make docs target, no Sphinx configuration), so the docs tox environment was intentionally omitted.
  • CI kept in parity with master — every job (the django42/django52 × Ubuntu 22.04/24.04 test matrix and quality) runs inside the Docker/AppArmor container via bash -c 'tox', exactly as on master. The only change to ci.yml is an added workflow_call trigger so release.yml can reuse it — so the required-check names are unchanged and branch protection needs no update.
  • Dockerfile migrated to uv + dependency groups — the Dockerfile no longer copies requirements/*.txt; it copies pyproject.toml/uv.lock and installs from dependency groups via uv pip install --group: the sandbox virtualenv from the sandbox group (numpy, six) and the main venv from the ci group (tox, tox-uv). A sandbox dependency group was added to mirror the old sandbox.in. No follow-up on the Docker-based test infrastructure is required.
  • commitlint.yml was already present — not added by this PR.
  • Conventional commit formatrelease.yml uses python-semantic-release which requires conventional commits (feat/fix/etc.) for automated versioning. All future PRs to this repo must use conventional commit format.
  • PSR baseline tag — existing git tags use v-prefixed format (e.g. v4.1.0) matching PSR's default tag_format = "v{version}". No manual baseline tag is required.

Testing Notes

This PR has not been manually tested against the repo's own features. Testing relied on CI checks and local agent tooling (make requirements, make quality, uv run python -m build). The Docker-based tests require AppArmor setup and cannot be run locally without the full Docker environment. Repo-owner is encouraged to run the repo's feature tests before merging.


🤖 Generated with Claude Code

farhan and others added 3 commits September 14, 2026 13:03
Part of openedx/public-engineering#517

- Migrate setup.py/setup.cfg metadata to pyproject.toml (PEP 621)
- Move package to src/ layout
- Switch to uv with PEP 735 dependency groups; commit uv.lock
- Replace pypi-release.yml with release.yml (OIDC trusted publishing via python-semantic-release)
- Update CI to use astral-sh/setup-uv for quality checks; Docker-based tests unchanged
- Add [tool.isort] and [tool.coverage] to pyproject.toml
- Update __version__ to use importlib.metadata
- Retain pylint/isort/pycodestyle as on master

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace requirements/*.txt file copies with uv-based installation.
Install uv system-wide and use it to install tox + tox-uv into the
main venv, replacing the old pip install -r requirements/testing.txt
and requirements/tox.txt invocations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The test suite imports numpy (test_importing_lots_of_crap), which
was previously provided via requirements/sandbox.txt in the tox
test environment. Add numpy to the test-base group to restore parity.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The package declares dynamic versioning (setuptools-scm), but __init__
still hardcoded '4.1.1', so codejail.__version__ would silently drift
from the real installed package version. Read it from installed
metadata instead, matching the pyproject dynamic-version setup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch from 327d31e to e6bdf44 Compare September 14, 2026 12:52
The Dockerfile hardcoded `pip install numpy six` because no dependency
group represented the sandbox deps — sandbox.in's packages had been
scattered (numpy into test-base, six into runtime). Add a `sandbox`
group mirroring sandbox.in and source test-base from it, so the
Dockerfile installs from groups (`--group sandbox`, `--group ci`)
instead of naming packages by hand. Drop the redundant numpy/six
install into the main venv — tox provisions them into its own env from
uv.lock.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch 2 times, most recently from 8f59ac8 to ff7c7a6 Compare September 14, 2026 14:53
The modernization moved quality to a native uv job (setup-uv + uv run
tox), which diverged from master and forced per-step conditionals or a
job split. codejail already ran quality inside the Docker/AppArmor
container on master via `docker exec ... tox` with TOXENV=quality, so
restore master's single-job CI verbatim and add only the `workflow_call`
trigger that release.yml needs. Net diff vs master: one added line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@farhan
farhan force-pushed the farhan/modernize-python-repo branch from ff7c7a6 to 7de502c Compare September 14, 2026 15:02
@farhan
farhan marked this pull request as ready for review September 14, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant