-
Notifications
You must be signed in to change notification settings - Fork 43
chore: modernize Python tooling (uv, PEP 621, semantic-release, src layout) #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
salman2013
wants to merge
9
commits into
openedx:master
Choose a base branch
from
salman2013:modernize-python-tooling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cad9ed8
chore: migrate package metadata to pyproject.toml (PEP 621)
salman2013 c0b4aa3
chore: switch dependency management from pip-tools to uv
salman2013 fa40927
chore: add python-semantic-release and commitlint workflows
salman2013 49e3811
refactor: migrate to src layout
salman2013 4768adf
fix: replace translations symlink with conf/locale in package-data
salman2013 e45edfe
fix: address review feedback from farhan
salman2013 e4b6ca3
fix: remove translations/** from package-data (symlink breaks wheel b…
salman2013 7df812d
fix: address review feedback from farhan
salman2013 f7ae64d
fix: fix make test posargs breaking CI
salman2013 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: Semantic Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| run_tests: | ||
| uses: ./.github/workflows/ci.yml | ||
| secrets: inherit | ||
| permissions: | ||
| contents: read | ||
|
|
||
| release: | ||
| needs: run_tests | ||
| if: github.ref_name == 'master' | ||
| runs-on: ubuntu-latest | ||
| concurrency: | ||
| group: ${{ github.workflow }}-release | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| ref: ${{ github.ref_name }} | ||
|
|
||
| - name: Reset to triggered commit | ||
| run: git reset --hard ${{ github.sha }} | ||
|
|
||
| - name: Python Semantic Release | ||
| id: release | ||
| uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 | ||
| with: | ||
| git_committer_name: "github-actions[bot]" | ||
| git_committer_email: "github-actions[bot]@users.noreply.github.com" | ||
| changelog: "false" | ||
|
|
||
| - name: Upload dist artifacts | ||
| if: steps.release.outputs.released == 'true' | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| outputs: | ||
| released: ${{ steps.release.outputs.released }} | ||
| version: ${{ steps.release.outputs.version }} | ||
|
|
||
| publish_to_pypi: | ||
| needs: release | ||
| if: needs.release.outputs.released == 'true' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Download dist artifacts | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,2 @@ | ||
| include LICENSE | ||
| include README.md | ||
| include requirements/base.in | ||
| include requirements/constraints.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| [build-system] | ||
| requires = ["setuptools", "setuptools-scm>8.1"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "xblock-image-explorer" | ||
| description = "XBlock - Image Explorer" | ||
| readme = "README.md" | ||
| license = "AGPL-3.0" | ||
| license-files = ["LICENSE"] | ||
| authors = [ | ||
| {name = "edX", email = "oscm@edx.org"}, | ||
| ] | ||
| keywords = ["Python", "edx", "xblock"] | ||
| classifiers = [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Framework :: Django", | ||
| "Framework :: Django :: 4.2", | ||
| "Framework :: Django :: 5.2", | ||
| "Intended Audience :: Developers", | ||
| "Natural Language :: English", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.12", | ||
| ] | ||
| requires-python = ">=3.12" | ||
| dynamic = ["version"] | ||
| dependencies = [ | ||
| "xblock[django]", | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/openedx/xblock-image-explorer" | ||
|
|
||
| [project.entry-points."xblock.v1"] | ||
| image-explorer = "image_explorer:ImageExplorerBlock" | ||
|
|
||
| [tool.setuptools_scm] | ||
| version_scheme = "only-version" | ||
| local_scheme = "no-local-version" | ||
| # Dummy version number for when .git isn't accessible. | ||
| # This happens, for example, when bind-mounting into a Docker image. | ||
| fallback_version = "0.0.0.dev0" | ||
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["src"] | ||
| include = ["image_explorer*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| "image_explorer" = [ | ||
| "static/**", | ||
| "templates/**", | ||
| "public/**", | ||
| "conf/locale/**", | ||
| ] | ||
|
|
||
| [tool.setuptools.exclude-package-data] | ||
| "*" = ["tests*", "*.tests*", "spec*", "*.spec*"] | ||
|
|
||
| [tool.coverage.run] | ||
| branch = true | ||
| source = ["image_explorer"] | ||
| omit = [ | ||
| "*/tests/*", | ||
| "*/migrations/*", | ||
| "*/__pycache__/*", | ||
| "*/settings.py", | ||
| ] | ||
|
|
||
| [tool.coverage.report] | ||
| show_missing = true | ||
| exclude_lines = [ | ||
| "pragma: no cover", | ||
| "def __repr__", | ||
| "raise AssertionError", | ||
| "raise NotImplementedError", | ||
| "if __name__ == .__main__.:", | ||
| "if TYPE_CHECKING:", | ||
| ] | ||
|
|
||
| [tool.coverage.html] | ||
| directory = "htmlcov" | ||
|
|
||
| [dependency-groups] | ||
| # Base test dependencies (no Django — pinned per group below) | ||
| test-base = [ | ||
| "mock", | ||
| "pytest-cov", | ||
| "pytest-django", | ||
| "xblock-sdk", | ||
| ] | ||
| # Default test group uses current supported Django (5.2) | ||
| test = [ | ||
| {include-group = "test-base"}, | ||
| "Django>=5.2,<6.0", | ||
| ] | ||
| # Legacy Django 4.2 support | ||
| django42 = [ | ||
| {include-group = "test-base"}, | ||
| "Django>=4.2,<5.0", | ||
| ] | ||
| quality = [ | ||
| {include-group = "test"}, | ||
| "edx-lint", | ||
| "pycodestyle", | ||
| ] | ||
| package = [ | ||
| "build", | ||
| "twine", | ||
| ] | ||
| # Minimal CI group — install first, then call uv run tox | ||
| ci = [ | ||
| "tox", | ||
| "tox-uv", | ||
| ] | ||
| dev = [ | ||
| {include-group = "quality"}, | ||
| {include-group = "ci"}, | ||
| {include-group = "package"}, | ||
| ] | ||
|
|
||
| [tool.semantic_release] | ||
| # version is dynamic via setuptools-scm; no version_toml needed | ||
| build_command = "python -m pip install --upgrade build && SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION python -m build" | ||
|
|
||
| [tool.edx_lint] | ||
| uv_constraints = [] | ||
|
|
||
| # NOTE: [tool.uv].constraint-dependencies is machine-managed. | ||
| # Run: uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml | ||
| [tool.uv] | ||
| package = true | ||
| conflicts = [ | ||
| [ | ||
| {group = "test"}, | ||
| {group = "django42"}, | ||
| ], | ||
| ] | ||
| constraint-dependencies = [ | ||
| "Django<6.0", | ||
| "elasticsearch<7.14.0", | ||
| ] | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translations/config.yamlis present in the repo (src/image_explorer/translations/) and was included in the master wheel, but is missing from the PR wheel. Add"translations/**"to[tool.setuptools.package-data]:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because translations/ in this repo is a symlink (git mode 120000) pointing to conf/locale/. Setuptools cannot copy symlinks as package data — it fails with:
error: can't copy 'src/image_explorer/translations': doesn't exist or not a regular file
The actual files (like config.yaml) live in conf/locale/, which is already covered by the existing "conf/locale/" entry. So adding "translations/" would be redundant and break the wheel build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed the translations setup — translations/config.yaml is the atlas config used to pull translation files into the source repo (via make pull_translations in the Makefile). Atlas reads the source tree, not the installed wheel, so this file doesn't need to be in the package. Closing this comment.
https://github.com/salman2013/xblock-image-explorer/blob/modernize-python-tooling/src/image_explorer/conf/locale/config.yaml
https://github.com/salman2013/xblock-image-explorer/blob/modernize-python-tooling/Makefile