diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a023449b..fde891c36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,8 +15,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.9 - - name: Upgrade pip - run: python -m pip install --upgrade pip setuptools - name: Install dependencies run: | pip install .[dev] diff --git a/.hatch_build.py b/.hatch_build.py new file mode 100644 index 000000000..8bf762e42 --- /dev/null +++ b/.hatch_build.py @@ -0,0 +1,20 @@ +# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/ +import os +import typing as t + +from hatchling.metadata.plugin.interface import MetadataHookInterface + +HERE = os.path.abspath(os.path.dirname(__file__)) + + +class JSONMetaDataHook(MetadataHookInterface): + def update(self, metadata: dict[str, t.Any]) -> None: + about = load_about() + metadata["version"] = about["__version__"] + + +def load_about() -> dict[str, str]: + about: dict[str, str] = {} + with open(os.path.join(HERE, "tutorindigo", "__about__.py"), "rt", encoding="utf-8") as f: + exec(f.read(), about) # pylint: disable=exec-used + return about diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 964e509ff..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include tutorindigo/templates * -recursive-include tutorindigo/patches * diff --git a/changelog.d/20250219_150716_ahmed.khalid_pyproject_toml.md b/changelog.d/20250219_150716_ahmed.khalid_pyproject_toml.md new file mode 100644 index 000000000..429d6c303 --- /dev/null +++ b/changelog.d/20250219_150716_ahmed.khalid_pyproject_toml.md @@ -0,0 +1 @@ +- [Improvement] Migrate from `setup.py` (setuptools) to `pyproject.toml` (hatch). (by @ahmed-arb) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d1e6ae6e5..9879752ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,58 @@ +#https://hatch.pypa.io/latest/config/build/ + +[project] +name = "tutor-indigo" +description = "Indigo theme plugin for Tutor" +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { text = "AGPLv3" } +requires-python = ">=3.9" +authors = [{ name = "Edly" }, { email = "hello@edly.io" }] +maintainers = [{ name = "Edly" }, { email = "hina.khadim@arbisoft.com" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = ["tutor-mfe>=19.0.0,<20.0.0", "tutor>=19.0.0,<20.0.0"] + +# hatch_build.py will set it later +dynamic = ["version"] + +[project.optional-dependencies] +dev = ["tutor[dev]>=19.0.0,<20.0.0"] + +[project.entry-points."tutor.plugin.v1"] +indigo = "tutorindigo.plugin" + +[project.urls] +Code = "https://github.com/overhangio/tutor-indigo" +Community = "https://discuss.openedx.org" +Documentation = "https://docs.tutor.edly.io/" +Homepage = "https://github.com/overhangio/tutor-indigo" +Changelog = "https://github.com/overhangio/tutor-indigo/blob/release/CHANGELOG.md" +Issues = "https://github.com/overhangio/tutor-indigo/issues" + +# hatch related configurations [build-system] -requires = ["setuptools", "wheel"] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.sdist] +# Disable strict naming, otherwise twine is not able to detect name/version +strict-naming = false +include = ["/tutorindigo"] +exclude = ["tests*"] + +# we need this becuase our project escapes default hatch file selection. +# see https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection +[tool.hatch.build.targets.wheel] +packages = ["/tutorindigo"] + +[tool.hatch.metadata.hooks.custom] +path = ".hatch_build.py" diff --git a/setup.py b/setup.py deleted file mode 100644 index 2a27cb9bd..000000000 --- a/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -import io -import os -from setuptools import setup, find_packages - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def load_readme(): - with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f: - return f.read() - - -def load_about(): - about = {} - with io.open( - os.path.join(HERE, "tutorindigo", "__about__.py"), - "rt", - encoding="utf-8", - ) as f: - exec(f.read(), about) # pylint: disable=exec-used - return about - - -ABOUT = load_about() - - -setup( - name="tutor-indigo", - version=ABOUT["__version__"], - url="https://github.com/overhangio/tutor-indigo", - project_urls={ - "Documentation": "https://docs.tutor.edly.io/", - "Code": "https://github.com/overhangio/tutor-indigo", - "Issue tracker": "https://github.com/overhangio/tutor-indigo/issues", - "Community": "https://discuss.openedx.org", - }, - license="AGPLv3", - author="Edly", - author_email="hello@edly.io", - maintainer="Edly", - maintainer_email="hina.khadim@arbisoft.com", - description="Indigo theme plugin for Tutor", - long_description=load_readme(), - long_description_content_type="text/x-rst", - packages=find_packages(exclude=["tests*"]), - include_package_data=True, - python_requires=">=3.9", - install_requires=["tutor>=19.0.0,<20.0.0", "tutor-mfe>=19.0.0,<20.0.0"], - extras_require={"dev": "tutor[dev]>=19.0.0,<20.0.0"}, - entry_points={"tutor.plugin.v1": ["indigo = tutorindigo.plugin"]}, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], -)