diff --git a/.hatch_build.py b/.hatch_build.py new file mode 100644 index 0000000..19a1f0b --- /dev/null +++ b/.hatch_build.py @@ -0,0 +1,22 @@ +# 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.dirname(__file__) + + +class MetaDataHook(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, "tutordash", "__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 c72be67..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include tutordash/server/static * -recursive-include tutordash/server/templates * diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5bbdbb6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,73 @@ +# https://packaging.python.org/en/latest/tutorials/packaging-projects/ +# https://hatch.pypa.io/latest/config/build/ + +[project] +name = "tutor-dash" +license = { text = "AGPL-3.0-only" } +authors = [ + {name = "Edly"}, + {email = "hello@edly.io"}, +] +maintainers = [ + {name = "Muhammad Labeeb"}, + {email = "muhammad.labeeb@arbisoft.com"}, +] +description = "Awesome administration dashboard and plugin marketplace for Tutor" +readme = {file = "README.rst", content-type = "text/x-rst"} +requires-python = ">= 3.9" +classifiers = [ + "Development Status :: 3 - Alpha", + "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>=19.0.0,<20.0.0", + "quart", + "aiofiles", + "markdown", + "click", + "click_repl", +] +# these fields will be set by hatch_build.py +dynamic = ["version"] + +[project.optional-dependencies] +dev = [ + "tutor[dev]>=19.0.0,<20.0.0", + "types-aiofiles", + "types-Markdown", + "pylint", + "black", +] + +[project.entry-points."tutor.plugin.v1"] +dash = "tutordash.plugin" + +# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels +[project.urls] +Homepage = "https://github.com/overhangio/tutor-dash" +Code = "https://github.com/overhangio/tutor-dash" +Issues = "https://github.com/overhangio/tutor-dash/issues" + +# hatch-specific configuration +[tool.hatch.metadata.hooks.custom] +path = ".hatch_build.py" + +[build-system] +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 = [ "/tutordash"] +exclude = ["tests*"] + +[tool.hatch.build.targets.wheel] +packages = ["tutordash"] diff --git a/setup.py b/setup.py deleted file mode 100644 index e9a038b..0000000 --- a/setup.py +++ /dev/null @@ -1,73 +0,0 @@ -import io -import os - -from setuptools import find_packages, setup - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def load_readme() -> str: - with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f: - return f.read() - - -def load_about() -> dict[str, str]: - about: dict[str, str] = {} - with io.open( - os.path.join(HERE, "tutordash", "__about__.py"), - "rt", - encoding="utf-8", - ) as f: - exec(f.read(), about) # pylint: disable=exec-used - return about - - -ABOUT = load_about() - - -setup( - name="tutor-dash", - version=ABOUT["__version__"], - url="https://github.com/overhangio/tutor-dash", - project_urls={ - "Code": "https://github.com/overhangio/tutor-dash", - "Issue tracker": "https://github.com/overhangio/tutor-dash/issues", - }, - license="AGPLv3", - author="Edly", - author_email="regis.behmo@edly.io", - description="Awesome administration dashboard and plugin marketplace 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", - "quart", - "aiofiles", - "markdown", - ], - extras_require={ - "dev": [ - "tutor[dev]>=19.0.0,<20.0.0", - "quart", - "aiofiles", - "types-aiofiles", - "click", - "click_repl", - ] - }, - entry_points={"tutor.plugin.v1": ["dash = tutordash.plugin"]}, - classifiers=[ - "Development Status :: 3 - Alpha", - "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", - ], -)