Skip to content

Commit d3f2f31

Browse files
ahmed-arbAhmed Khalid
and
Ahmed Khalid
authored
feat: migrate from setup.py to pyproject.toml (#130)
Co-authored-by: Ahmed Khalid <[email protected]>
1 parent a1ae597 commit d3f2f31

File tree

6 files changed

+78
-67
lines changed

6 files changed

+78
-67
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
uses: actions/setup-python@v2
1616
with:
1717
python-version: 3.9
18-
- name: Upgrade pip
19-
run: python -m pip install --upgrade pip setuptools
2018
- name: Install dependencies
2119
run: |
2220
pip install .[dev]

.hatch_build.py

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

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Migrate from `setup.py` (setuptools) to `pyproject.toml` (hatch). (by @ahmed-arb)

pyproject.toml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,58 @@
1+
#https://hatch.pypa.io/latest/config/build/
2+
3+
[project]
4+
name = "tutor-indigo"
5+
description = "Indigo theme plugin for Tutor"
6+
readme = { file = "README.rst", content-type = "text/x-rst" }
7+
license = { text = "AGPLv3" }
8+
requires-python = ">=3.9"
9+
authors = [{ name = "Edly" }, { email = "[email protected]" }]
10+
maintainers = [{ name = "Edly" }, { email = "[email protected]" }]
11+
classifiers = [
12+
"Development Status :: 5 - Production/Stable",
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.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
]
22+
dependencies = ["tutor-mfe>=19.0.0,<20.0.0", "tutor>=19.0.0,<20.0.0"]
23+
24+
# hatch_build.py will set it later
25+
dynamic = ["version"]
26+
27+
[project.optional-dependencies]
28+
dev = ["tutor[dev]>=19.0.0,<20.0.0"]
29+
30+
[project.entry-points."tutor.plugin.v1"]
31+
indigo = "tutorindigo.plugin"
32+
33+
[project.urls]
34+
Code = "https://github.com/overhangio/tutor-indigo"
35+
Community = "https://discuss.openedx.org"
36+
Documentation = "https://docs.tutor.edly.io/"
37+
Homepage = "https://github.com/overhangio/tutor-indigo"
38+
Changelog = "https://github.com/overhangio/tutor-indigo/blob/release/CHANGELOG.md"
39+
Issues = "https://github.com/overhangio/tutor-indigo/issues"
40+
41+
# hatch related configurations
142
[build-system]
2-
requires = ["setuptools", "wheel"]
43+
requires = ["hatchling"]
44+
build-backend = "hatchling.build"
45+
46+
[tool.hatch.build.targets.sdist]
47+
# Disable strict naming, otherwise twine is not able to detect name/version
48+
strict-naming = false
49+
include = ["/tutorindigo"]
50+
exclude = ["tests*"]
51+
52+
# we need this becuase our project escapes default hatch file selection.
53+
# see https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection
54+
[tool.hatch.build.targets.wheel]
55+
packages = ["/tutorindigo"]
56+
57+
[tool.hatch.metadata.hooks.custom]
58+
path = ".hatch_build.py"

setup.py

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

0 commit comments

Comments
 (0)