From bfd792926edb4fef3aa02e0d52291d2c636ec2fa Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 26 May 2023 07:45:38 +0200 Subject: [PATCH] fix #840 - return to setuptools --- CHANGELOG.rst | 1 - _own_version_helper.py | 16 ++++++++++++++++ pyproject.toml | 21 +++++++++++++-------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 51d74cf8..23d9cd74 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,7 +8,6 @@ breaking * turn Configuration into a dataclass * require configuration to always pass into helpers * hide file-finders implementation in private module -* migrate to hatchling * renamed setuptools_scm.hacks to setuptools_scm.fallbacks and drop support for pip-egg-info * remove trace function and use logging instead * unify distance=None and distance=0 they should mean the same diff --git a/_own_version_helper.py b/_own_version_helper.py index e40cb63d..9339773b 100644 --- a/_own_version_helper.py +++ b/_own_version_helper.py @@ -1,12 +1,17 @@ """ this module is a hack only in place to allow for setuptools to use the attribute for the versions + +it works only if the backend-path of the build-system section +from pyproject.toml is respected """ from __future__ import annotations import logging from typing import Callable +from setuptools.build_meta import * # noqa + from setuptools_scm import _types as _t from setuptools_scm import Configuration from setuptools_scm import get_version @@ -48,3 +53,14 @@ def scm_version() -> str: version_scheme=guess_next_dev_version, local_scheme=get_local_node_and_date, ) + + +version: str + + +def __getattr__(name: str) -> str: + if name == "version": + global version + version = scm_version() + return version + raise AttributeError(name) diff --git a/pyproject.toml b/pyproject.toml index 253a64bd..ac553360 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,19 @@ [build-system] -build-backend = "hatchling.build" +build-backend = "_own_version_helper" requires = [ - "hatchling>=1.10", 'importlib-metadata>=4.6; python_version < "3.10"', "packaging>=20", - "setuptools>=55", + "rich", + "setuptools>=61", 'tomli; python_version < "3.11"', 'typing_extensions; python_version < "3.8"', ] +backend-path = [ + ".", + "src", +] [project] name = "setuptools-scm" @@ -94,8 +98,9 @@ PKG-INFO = "setuptools_scm.fallbacks:parse_pkginfo" "python-simplified-semver" = "setuptools_scm.version:simplified_semver_version" "release-branch-semver" = "setuptools_scm.version:release_branch_semver_version" -[tool.hatch.version] -source = "code" -path = "_own_version_helper.py" -search-paths = ["src"] -expression = "scm_version()" +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + +[tool.setuptools.dynamic] +version = { attr = "_own_version_helper.version"}