Skip to content

Commit ef8a30f

Browse files
authored
feat: migrate from setup.py to pyproject.toml (#38)
* feat: migrate from setup.py to pyproject.toml * chore: addressing PR comments * chore: addressing more comments
1 parent 02a4b1e commit ef8a30f

File tree

6 files changed

+84
-57
lines changed

6 files changed

+84
-57
lines changed

.github/workflows/test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ jobs:
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
21-
- name: Upgrade pip
22-
run: python -m pip install --upgrade pip setuptools
2321
- name: Install dependencies
2422
run: |
2523
pip install .[dev]

.hatch_build.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/
2+
3+
import os
4+
import typing as t
5+
6+
from hatchling.metadata.plugin.interface import MetadataHookInterface
7+
8+
HERE = os.path.dirname(__file__)
9+
10+
11+
class MetaDataHook(MetadataHookInterface):
12+
def update(self, metadata: dict[str, t.Any]) -> None:
13+
about = load_about()
14+
metadata["version"] = about["__version__"]
15+
16+
17+
def load_about() -> dict[str, str]:
18+
about: dict[str, str] = {}
19+
with open(os.path.join(HERE, "tutorxqueue", "__about__.py"), "rt", encoding="utf-8") as f:
20+
exec(f.read(), about) # pylint: disable=exec-used
21+
return about

MANIFEST.in

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Migrate from `setup.py` (setuptools) to `pyproject.toml` (hatch). (by @jfavellar90)

pyproject.toml

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1+
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
2+
# https://hatch.pypa.io/latest/config/build/
3+
4+
[project]
5+
name = "tutor-xqueue"
6+
description = "A Tutor plugin for Xqueue (external grading system)"
7+
authors = [
8+
{ name = "Edly" },
9+
{ email = "[email protected]"},
10+
]
11+
maintainers = [
12+
{ name = "Jhony Avella" },
13+
{ email = "[email protected]" },
14+
]
15+
license = {text = "AGPL-3.0-only"}
16+
readme = {file = "README.rst", content-type = "text/x-rst"}
17+
requires-python = ">=3.9"
18+
classifiers = [
19+
"Development Status :: 5 - Production/Stable",
20+
"Intended Audience :: Developers",
21+
"License :: OSI Approved :: GNU Affero General Public License v3",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
]
29+
dependencies = [
30+
"tutor>=19.0.0,<20.0.0",
31+
]
32+
optional-dependencies = { dev = ["tutor[dev]>=19.0.0,<20.0.0"] }
33+
34+
# These fields will be set by hatch_build.py
35+
dynamic = ["version"]
36+
37+
# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
38+
[project.urls]
39+
Homepage = "https://docs.tutor.edly.io/"
40+
Documentation = "https://github.com/overhangio/tutor-xqueue#readme"
41+
Issues = "https://github.com/overhangio/tutor-xqueue/issues"
42+
Source = "https://github.com/overhangio/tutor-xqueue"
43+
Changelog = "https://github.com/overhangio/tutor-xqueue/blob/release/CHANGELOG.md"
44+
Community = "https://discuss.openedx.org/tag/tutor"
45+
146
[build-system]
2-
requires = ["setuptools", "wheel"]
47+
requires = ["hatchling"]
48+
build-backend = "hatchling.build"
49+
50+
# hatch-specific configuration
51+
[tool.hatch.metadata.hooks.custom]
52+
path = ".hatch_build.py"
53+
54+
[tool.hatch.build.targets.wheel]
55+
packages = ["tutorxqueue"]
56+
57+
[tool.hatch.build.targets.sdist]
58+
# Disable strict naming, otherwise twine is not able to detect name/version
59+
strict-naming = false
60+
include = [ "/tutorxqueue"]
61+
62+
[project.entry-points."tutor.plugin.v1"]
63+
xqueue = "tutorxqueue.plugin"

setup.py

-52
This file was deleted.

0 commit comments

Comments
 (0)