diff --git a/src/regolith/version.py b/src/regolith/version.py index 04517257c..a7fbc220f 100644 --- a/src/regolith/version.py +++ b/src/regolith/version.py @@ -22,37 +22,49 @@ Use `__git_commit__` instead. """ -__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] - -import os.path -from importlib.resources import as_file, files - -# obtain version information from the version.cfg file -cp = dict(version="", date="", commit="", timestamp="0") -if __package__ is not None: - ref = files(__package__) / "version.cfg" - with as_file(ref) as fcfg: - if not os.path.isfile(fcfg): # pragma: no cover - from warnings import warn - - warn("Package metadata not found.") - fcfg = os.devnull - with open(fcfg) as fp: - kwords = [ - [w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line - ] - assert all(w[0] in cp for w in kwords), "received unrecognized keyword" - cp.update(kwords) - del kwords - -__version__ = cp["version"] -__date__ = cp["date"] -__git_commit__ = cp["commit"] -__timestamp__ = int(cp["timestamp"]) +# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] + +# import os.path + +# obtain version information +from importlib.metadata import version + +# from importlib.resources import as_file, files +# +# # obtain version information from the version.cfg file +# cp = dict(version="", date="", commit="", timestamp="0") +# if __package__ is not None: +# ref = files(__package__) / "version.cfg" +# with as_file(ref) as fcfg: +# if not os.path.isfile(fcfg): # pragma: no cover +# from warnings import warn +# +# warn("Package metadata not found.") +# fcfg = os.devnull +# with open(fcfg) as fp: +# kwords = [ +# [w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line +# ] +# assert all(w[0] in cp for w in kwords), "received unrecognized keyword" +# cp.update(kwords) +# del kwords +# +# __version__ = cp["version"] +# __date__ = cp["date"] +# __git_commit__ = cp["commit"] +# __timestamp__ = int(cp["timestamp"]) # TODO remove deprecated __gitsha__ in version 3.1. -__gitsha__ = __git_commit__ +# __gitsha__ = __git_commit__ +# +# del cp + +# from cookiecutter in case we want to migrate later: +# +# # We do not use the other three variables, but can be added back if needed. +# # __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] + -del cp +__version__ = version("regolith") # End of file