From e73901b08b42241d7293f5c7e796aaf69c6ed81e Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Thu, 28 Mar 2024 19:11:57 +0100 Subject: [PATCH] [pyproject] Use hatch and versioningit for modern project management --- .gitignore | 1 - MANIFEST.in | 7 ---- conda/meta.yaml | 4 +-- pyproject.toml | 90 ++++++++++++++++++++++++++----------------------- setup.py | 7 ---- 5 files changed, 48 insertions(+), 61 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 97b97ca..25128ff 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ coverage.xml test_results.xml junit-coverage.xml -environment.yaml html/ build/ doc/api/ diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 12e13c1..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: Copyright © 2022 Idiap Research Institute <contact@idiap.ch> -# -# SPDX-License-Identifier: BSD-3-Clause - -include LICENSES/*.txt -recursive-include doc *.rst *.txt *.py -recursive-include tests *.py *.cfg diff --git a/conda/meta.yaml b/conda/meta.yaml index 8e71430..3a3ae88 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -2,11 +2,9 @@ # # SPDX-License-Identifier: BSD-3-Clause -{% set data = load_file_data(RECIPE_DIR + '/../pyproject.toml') %} - package: name: {{ data['project']['name'] }} - version: {{ data['project']['version'] }} + version: {{ environ.get('PACKAGE_VERSION', environ.get('GIT_DESCRIBE_TAG')) }} source: path: .. diff --git a/pyproject.toml b/pyproject.toml index e9f1e31..308d69e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,34 +3,53 @@ # SPDX-License-Identifier: BSD-3-Clause [build-system] - requires = ["setuptools>=61.0.0", "wheel"] - build-backend = "setuptools.build_meta" +requires = ["hatchling", "versioningit"] +build-backend = "hatchling.build" [project] name = "clapper" -version = "1.0.2b0" +dynamic = ["version"] requires-python = ">=3.10" description = "Configuration Support for Python Packages and CLIs" readme = "README.md" -license = {text = "BSD 3-Clause License"} -authors = [ - {name = "Andre Anjos", email = "andre.anjos@idiap.ch"}, -] +license = { text = "BSD 3-Clause License" } +authors = [{ name = "Andre Anjos", email = "andre.anjos@idiap.ch" }] classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Topic :: Software Development :: Libraries :: Python Modules", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Python Modules", ] -dependencies = [ - "click>=8", - "tomli", - "tomli-w", - "xdg", +dependencies = ["click>=8", "tomli", "tomli-w", "xdg"] + +[tool.hatch.version] +source = "versioningit" + +[tool.versioningit.next-version] +method = "smallest" + +[tool.versioningit.format] +# Example formatted version: 1.2.4.dev42+ge174a1f +distance = "{next_version}.dev{distance}+{vcs}{rev}" +# Example formatted version: 1.2.4.dev42+ge174a1f.d20230922 +distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}" + +[tool.hatch.build.targets.sdist] +include = [ + "src/**/*.py", + "tests/**/*.py", + "tests/**/*.cfg", + "doc/**/*.rst", + "doc/**/*.txt", + "doc/**/*.py", + "LICENSES/*.txt", ] +[tool.hatch.build.targets.wheel] +packages = ["src/clapper"] + [project.urls] documentation = "https://clapper.readthedocs.io/en/latest/" homepage = "https://pypi.org/project/clapper" @@ -40,19 +59,15 @@ changelog = "https://gitlab.idiap.ch/software/clapper/-/releases" [project.optional-dependencies] qa = ["pre-commit"] doc = [ - "sphinx", - "furo", - "sphinx-autodoc-typehints", - "sphinxcontrib-programoutput", - "auto-intersphinx", - "sphinx-copybutton", - "sphinx-inline-tabs", - ] -test = [ - "pytest", - "pytest-cov", - "coverage", - ] + "sphinx", + "furo", + "sphinx-autodoc-typehints", + "sphinxcontrib-programoutput", + "auto-intersphinx", + "sphinx-copybutton", + "sphinx-inline-tabs", +] +test = ["pytest", "pytest-cov", "coverage"] [project.entry-points."clapper.test.config"] first = "tests.data.basic_config" @@ -66,13 +81,6 @@ complex-var = "tests.data.complex:cplx" verbose-config = "tests.data.verbose_config" error-config = "tests.data.doesnt_exist" -[tool.setuptools] -zip-safe = true -package-dir = {"" = "src"} - -[tool.distutils.bdist_wheel] -universal = true - [tool.isort] profile = "black" line_length = 80 @@ -83,10 +91,6 @@ lines_between_types = 1 line-length = 80 [tool.pytest.ini_options] -addopts = [ - "--cov=clapper", - "--cov-report=term-missing", - "--import-mode=append", -] +addopts = ["--cov=clapper", "--cov-report=term-missing", "--import-mode=append"] junit_logging = "all" junit_log_passing_tests = false diff --git a/setup.py b/setup.py deleted file mode 100644 index 1049028..0000000 --- a/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: Copyright © 2022 Idiap Research Institute <contact@idiap.ch> -# -# SPDX-License-Identifier: BSD-3-Clause - -from setuptools import setup - -setup() -- GitLab