Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
branches:
- '**'
workflow_dispatch:
workflow_call:

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
tests:
name: ${{ matrix.toxenv }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -22,21 +24,23 @@ jobs:
python-version: ['3.12']
toxenv: [django42, django52, quality, package]

permissions:
contents: read

steps:
- name: checkout repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
submodules: recursive

- name: setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: make requirements
- name: Install CI dependencies
run: uv sync --group ci

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
run: uv run tox -e ${{ matrix.toxenv }}
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/release.yml
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
2 changes: 0 additions & 2 deletions MANIFEST.in
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
37 changes: 13 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.PHONY: clean compile_translations dummy_translations \
extract_translations dummy_translations help
extract_translations dummy_translations help \
test quality

.DEFAULT_GOAL := help

WORKING_DIR := image_explorer
WORKING_DIR := src/image_explorer
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
Expand All @@ -22,31 +23,19 @@ clean: ## remove generated byte code, coverage reports, and build artifacts
rm -fr dist/
rm -fr *.egg-info

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip.txt
pip install -r requirements/pip-tools.txt
test: ## run tests
mkdir -p var
pytest $(posargs)

requirements: piptools ## install test requirements locally
pip-sync requirements/ci.txt
quality: ## run linting
pylint --fail-under=9.0 src/image_explorer

requirements_python: piptools ## install all requirements locally
pip-sync requirements/base.txt requirements/ci.txt requirements/test.txt requirements/private.*
requirements: ## install development environment requirements
uv sync --group dev

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
sed -i '/^[dD]jango==/d' requirements/test.txt
upgrade: ## update uv.lock and constraints with the latest packages
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

## Localization targets

Expand Down
141 changes: 141 additions & 0 deletions pyproject.toml
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/**",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translations/config.yaml is 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]:

[tool.setuptools.package-data]
"image_explorer" = [
    "static/**",
    "templates/**",
    "public/**",
    "conf/locale/**",
    "translations/**",
]

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown

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

]

[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",
]
4 changes: 0 additions & 4 deletions requirements/base.in

This file was deleted.

Loading