diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-21 11:21:57 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-29 17:04:12 +0200 |
commit | f0128253816d5d1783c6c1def4cc8957a34d3436 (patch) | |
tree | c1fb3300bcd65d8aaabbc0a3bf4739166b5d8245 /src/setuptools_scm/hacks.py | |
parent | e9715c1f9e506735f6de15559089827000ad2058 (diff) | |
download | setuptools-scm-f0128253816d5d1783c6c1def4cc8957a34d3436.tar.gz |
rename .hacks to .fallbacks and drop support for pip-egg-info
Diffstat (limited to 'src/setuptools_scm/hacks.py')
-rw-r--r-- | src/setuptools_scm/hacks.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/setuptools_scm/hacks.py b/src/setuptools_scm/hacks.py deleted file mode 100644 index 5aaa0db..0000000 --- a/src/setuptools_scm/hacks.py +++ /dev/null @@ -1,52 +0,0 @@ -from __future__ import annotations - -import os -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from . import _types as _t -from . import Configuration -from .utils import data_from_mime -from ._trace import trace -from .version import meta -from .version import ScmVersion -from .version import tag_to_version - -_UNKNOWN = "UNKNOWN" - - -def parse_pkginfo(root: _t.PathT, config: Configuration) -> ScmVersion | None: - pkginfo = os.path.join(root, "PKG-INFO") - trace("pkginfo", pkginfo) - data = data_from_mime(pkginfo) - version = data.get("Version", _UNKNOWN) - if version != _UNKNOWN: - return meta(version, preformatted=True, config=config) - else: - return None - - -def parse_pip_egg_info(root: _t.PathT, config: Configuration) -> ScmVersion | None: - pipdir = os.path.join(root, "pip-egg-info") - if not os.path.isdir(pipdir): - return None - items = os.listdir(pipdir) - trace("pip-egg-info", pipdir, items) - if not items: - return None - return parse_pkginfo(os.path.join(pipdir, items[0]), config=config) - - -def fallback_version(root: _t.PathT, config: Configuration) -> ScmVersion | None: - if config.parentdir_prefix_version is not None: - _, parent_name = os.path.split(os.path.abspath(root)) - if parent_name.startswith(config.parentdir_prefix_version): - version = tag_to_version( - parent_name[len(config.parentdir_prefix_version) :], config - ) - if version is not None: - return meta(str(version), preformatted=True, config=config) - if config.fallback_version is not None: - trace("FALLBACK") - return meta(config.fallback_version, preformatted=True, config=config) - return None |