Skip to content

Commit ba47cb6

Browse files
committed
build: move to a uv based project management setup
1 parent e47e30e commit ba47cb6

10 files changed

Lines changed: 924 additions & 140 deletions

File tree

Makefile

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,24 @@
1-
.PHONY: quality help requirements\
2-
piptools selfcheck upgrade test clean
3-
41
.DEFAULT_GOAL := help
2+
.PHONY: help
53

6-
piptools: ## install pinned version of pip-compile and pip-sync
7-
pip install -r requirements/pip-tools.txt
8-
9-
help: ## display this help message
10-
@echo "Please use \`make <target>' where <target> is one of"
11-
@awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
12-
13-
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
14-
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)
15-
16-
clean: ## remove generated byte code, coverage reports, and build artifacts
17-
find tutorcodejail -name '__pycache__' -exec rm -rf {} +
18-
find tutorcodejail -name '*.pyc' -exec rm -f {} +
19-
find tutorcodejail -name '*.pyo' -exec rm -f {} +
20-
find tutorcodejail -name '*~' -exec rm -f {} +
21-
coverage erase
22-
rm -fr build/
23-
rm -fr dist/
24-
rm -fr *.egg-info
25-
4+
quality: ## Run linters
5+
uv run ruff check
6+
uv run ruff format --diff
7+
uv run ty check
268

27-
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
28-
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
29-
make piptools
30-
# Make sure to compile files after any other files they include!
31-
$(PIP_COMPILE) --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in
32-
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
33-
make piptools
34-
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
35-
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
9+
quality-fix: ## Run automatic linter fixes
10+
uv run ruff format
11+
uv run ruff check --fix
3612

37-
quality: ## check coding style with pycodestyle and pylint
38-
pylint tutorcodejail *.py
39-
isort --check-only --diff --recursive tutorcodejail *.py
40-
python setup.py bdist_wheel
41-
twine check dist/*
42-
make selfcheck
13+
changelog-entry: ## Run scriv to create a changelog entry
14+
uv run scriv create
4315

44-
requirements: ## install development environment requirements
45-
pip install -r requirements/pip.txt
46-
pip install -r requirements/pip-tools.txt
47-
pip-sync requirements/dev.txt
48-
pip install -e .
16+
changelog-collect: ## Collect all the changelog entries and rebuild CHANGELOG.md
17+
uv run scriv collect
4918

50-
test: ## run unitary tests and meassure coverage
51-
coverage run -m pytest
52-
coverage report -m --fail-under=62
53-
@echo "Testing module buiding..."
19+
ESCAPE = 
20+
help: ## Print this help
21+
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
22+
| sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \
23+
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
5424

55-
selfcheck: ## check that the Makefile is well-formed
56-
@echo "The Makefile is well-formed."

pyproject.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[project]
2+
name = "tutor-contrib-codejail"
3+
version = "21.0.0"
4+
description = "Codejail plugin for Tutor"
5+
readme = "README.rst"
6+
requires-python = ">=3.10"
7+
license = { file = "LICENSE" }
8+
authors = [
9+
{ name = "eduNEXT" }
10+
]
11+
classifiers = [
12+
"Development Status :: 3 - Alpha",
13+
"Intended Audience :: Developers",
14+
"License :: OSI Approved :: GNU Affero General Public License v3",
15+
"Operating System :: OS Independent",
16+
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
]
21+
dependencies = [
22+
"tutor~=21.0"
23+
]
24+
[project.urls]
25+
Homepage = "https://github.com/edunext/tutor-contrib-codejail"
26+
Code = "https://github.com/edunext/tutor-contrib-codejail"
27+
"Issue tracker" = "https://github.com/edunext/tutor-contrib-codejail/issues"
28+
29+
[project.entry-points."tutor.plugin.v1"]
30+
codejail = "tutorcodejail.plugin"
31+
32+
[tool.ruff]
33+
line-length = 120
34+
indent-width = 4
35+
lint.select = [
36+
"E4",
37+
"E7",
38+
"E9",
39+
"F",
40+
"I",
41+
"UP",
42+
]
43+
extend-exclude = ["tutorcodejail/patches", "tutorcodejail/templates"]
44+
45+
[tool.ty.src]
46+
exclude = ["tutorcodejail/patches", "tutorcodejail/templates"]
47+
48+
[tool.scriv]
49+
version = "literal: pyproject.toml: project.version"
50+
categories = "Added, Changed, Fixed, Removed"
51+
format = "md"
52+
md_header_level = 2
53+
new_fragment_template = "file: changelog.d/scriv/new_fragment.md.j2"
54+
entry_title_template = "file: changelog.d/scriv/entry_title.md.j2"
55+
56+
[build-system]
57+
requires = ["uv_build>=0.9.5,<0.10.0"]
58+
build-backend = "uv_build"
59+
60+
[dependency-groups]
61+
dev = [
62+
"ruff>=0.15.0",
63+
"scriv>=1.8.0",
64+
"ty>=0.0.16",
65+
]
66+
67+
[tool.uv.build-backend]
68+
module-root = "."
69+
module-name = "tutorcodejail"
70+

setup.cfg

Lines changed: 0 additions & 23 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

tutorcodejail/__about__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
"""Helps you keep your cool when creating dozens of open edX and eduNEXT environments."""
2+
23
__version__ = "21.0.0"

tutorcodejail/patches/.gitignore

Whitespace-only changes.

tutorcodejail/plugin.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import os
6-
import typing as t
76
from glob import glob
87
from pathlib import Path
98

@@ -75,7 +74,7 @@ def get_apparmor_abi():
7574

7675
@hooks.Filters.IMAGES_BUILD.add()
7776
def _build_codejail_images(
78-
images: list[tuple[str, t.Union[str, tuple[str, ...]], str, tuple[str, ...]]],
77+
images: list[tuple[str, str | tuple[str, ...], str, tuple[str, ...]]],
7978
tutor_config: Config,
8079
):
8180
"""Choose the appropiate build context when using CODEJAIL_USE_SERVICE_V2."""
@@ -106,7 +105,7 @@ def _build_codejail_images(
106105

107106
@hooks.Filters.IMAGES_PUSH.add()
108107
def _push_codejail_images(
109-
images: list[tuple[str, t.Union[str, tuple[str, ...]], str, tuple[str, ...]]],
108+
images: list[tuple[str, str | tuple[str, ...], str, tuple[str, ...]]],
110109
tutor_config: Config,
111110
):
112111
"""Choose the appropiate image tag when using CODEJAIL_USE_SERVICE_V2."""
@@ -130,9 +129,7 @@ def _push_codejail_images(
130129

131130
# Boilerplate code
132131
# Add the "templates" folder as a template root
133-
hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
134-
str(importlib_resources.files("tutorcodejail") / "templates")
135-
)
132+
hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(str(importlib_resources.files("tutorcodejail") / "templates"))
136133
# Render the "build" and "apps" folders
137134
hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
138135
[
@@ -149,7 +146,5 @@ def _push_codejail_images(
149146
hooks.Filters.CONFIG_DEFAULTS.add_items(
150147
[(f"CODEJAIL_{key}", value) for key, value in config.get("defaults", {}).items()]
151148
)
152-
hooks.Filters.CONFIG_UNIQUE.add_items(
153-
[(f"CODEJAIL_{key}", value) for key, value in config.get("unique", {}).items()]
154-
)
149+
hooks.Filters.CONFIG_UNIQUE.add_items([(f"CODEJAIL_{key}", value) for key, value in config.get("unique", {}).items()])
155150
hooks.Filters.CONFIG_OVERRIDES.add_items(list(config.get("overrides", {}).items()))

tutorcodejail/templates/codejail/apps/.gitignore

Whitespace-only changes.

tutorcodejail/templates/codejail/build/.gitignore

Whitespace-only changes.

0 commit comments

Comments
 (0)