diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 689c592a5..734d7ab67 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -43,10 +43,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools setuptools-scm wheel twine - - name: Build a binary wheel and a source tarball - run: | - python setup.py sdist bdist_wheel + pip install -r dev_requirements/requirements-packaging.txt + - name: Build wheel and source distributions + run: python -m build - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index 9f3741e1d..6c0160ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,7 @@ Temporary Items docs/api docs/plantuml.jar docs/_static/images + +# version number for bo4e-python; gets auto-generated during the command +# python -m build +src/_bo4e_python_version.py diff --git a/dev_requirements/requirements-packaging.in b/dev_requirements/requirements-packaging.in index ae57afe11..9fef06202 100644 --- a/dev_requirements/requirements-packaging.in +++ b/dev_requirements/requirements-packaging.in @@ -1,3 +1,3 @@ -# requirements for the hatchling build ssystem +# requirements for the hatchling build system +build twine -wheel diff --git a/docs/conf.py b/docs/conf.py index a6cf4ab1e..8fd322ff1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,7 @@ # https://github.com/rtfd/readthedocs.org/issues/1139 # DON'T FORGET: Check the box "Install your project inside a virtualenv using # setup.py install" in the RTD Advanced Settings. -# Additionally it helps us to avoid running apidoc manually +# Additionally, it helps us to avoid running apidoc manually try: # for Sphinx >= 1.7 from sphinx.ext import apidoc diff --git a/pyproject.toml b/pyproject.toml index 3b23a9ad7..b26e2f609 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,56 @@ [build-system] -requires = ["setuptools>=41.0", "wheel", "setuptools_scm[toml]>=3.4"] -build-backend = "setuptools.build_meta" +requires = ["hatchling>=1.8.0", "hatch-vcs", "hatch-fancy-pypi-readme"] +build-backend = "hatchling.build" + +[project] +name = "bo4e-python" +description = "Python Library that implements the BO4E Standard." +license = { text = "MIT" } +requires-python = ">=3.10" +authors = [{ name = "Kevin Krechan", email = "kevin.krechan@hochfrequenz.de" }] +keywords = ["bo4e", "bdew", "edi@energy"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +# This list must be in synq with the ./requirements.in file! +dependencies = [ + "iso3166", + "pydantic>=2.0.0", + "pyhumps", +] +dynamic = ["readme", "version"] + +[project.urls] +Changelog = "https://github.com/bo4e/bo4e-python/releases" +Homepage = "https://github.com/bo4e/bo4e-python" +Documentation = "https://bo4e-python.readthedocs.io/en/latest/" + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/x-rst" +fragments = [{ path = "README.rst" }] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/_bo4e_python_version.py" +template = ''' +version = "{version}" +''' + +[tool.hatch.build.targets.sdist] +exclude = ["/unittests"] + +[tool.hatch.build.targets.wheel] +only-include = ["src"] +sources = ["src"] [tool.black] line-length = 120 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a288f30d0..000000000 --- a/setup.cfg +++ /dev/null @@ -1,38 +0,0 @@ -[metadata] -url = https://github.com/Hochfrequenz/BO4E-python -project_urls = - Documentation = https://bo4e-python.readthedocs.io/en/latest/ - Code = https://github.com/Hochfrequenz/BO4E-python - Issue tracker = https://github.com/Hochfrequenz/BO4E-python/issues -license = mit -author = Kevin Krechan -author_email = kevin.krechan@hochfrequenz.de -description = Python Library that implements the BO4E Standard. -long_description = file: README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -platforms = any -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.10 - -[options] -zip_safe = False -packages = find: -package_dir = = src -include_package_data = True -python_requires = >=3.10 -install_requires = - iso3166 - pydantic>=2.0.0 - pyhumps - -[options.packages.find] -where = src -exclude = - tests - -[options.package_data] -* = py.typed diff --git a/setup.py b/setup.py deleted file mode 100644 index d0df000c5..000000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -import sys - -from setuptools import setup - -min_version = (3, 10) - -if sys.version_info < min_version: - error = f""" -bo4e needs Python {min_version} or above. -You are using Python {sys.version_info} -""".format( - ".".join(str(n) for n in min_version), - ".".join(str(n) for n in sys.version_info[:3]), - ) - sys.exit(error) - -setup(name="bo4e", use_scm_version=True)