diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-20 17:19:56 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-20 17:19:56 +0100 |
commit | 43dc36fb429aa4079a160d30bf9dfc4059969048 (patch) | |
tree | 5a9598f1d937f4472262f68d675339a2025b3128 /_own_version_helper.py | |
parent | 4b33e3b341d4492d419da93e8e0f57d5279dbd52 (diff) | |
download | setuptools-scm-43dc36fb429aa4079a160d30bf9dfc4059969048.tar.gz |
migrate to hatchling build backend
Diffstat (limited to '_own_version_helper.py')
-rw-r--r-- | _own_version_helper.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/_own_version_helper.py b/_own_version_helper.py new file mode 100644 index 0000000..b7069ba --- /dev/null +++ b/_own_version_helper.py @@ -0,0 +1,30 @@ +""" +this module is a hack only in place to allow for setuptools +to use the attribute for the versions +""" +from __future__ import annotations + +from setuptools_scm import Configuration +from setuptools_scm import get_version +from setuptools_scm import git +from setuptools_scm import hg +from setuptools_scm.hacks import parse_pkginfo +from setuptools_scm.version import get_local_node_and_date +from setuptools_scm.version import guess_next_dev_version +from setuptools_scm.version import ScmVersion + + +def parse(root: str, config: Configuration) -> ScmVersion | None: + try: + return parse_pkginfo(root, config) + except OSError: + return git.parse(root, config=config) or hg.parse(root, config=config) + + +def scm_version() -> str: + return get_version( + relative_to=__file__, + parse=parse, + version_scheme=guess_next_dev_version, + local_scheme=get_local_node_and_date, + ) |