From b2a907bc7f067e501bce12d84427a371bf8914b5 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Wed, 21 Aug 2024 08:51:15 -0400 Subject: [PATCH] try version fix --- src/diffpy/pdfgui/version.py | 40 ++++++------------------------------ 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/diffpy/pdfgui/version.py b/src/diffpy/pdfgui/version.py index 037c944b..faf07aea 100644 --- a/src/diffpy/pdfgui/version.py +++ b/src/diffpy/pdfgui/version.py @@ -13,41 +13,13 @@ # ############################################################################## -""" -Definition of __version__, __date__, __timestamp__, __git_commit__. +"""Definition of __version__ and __date__.""" -Notes ------ -Variable `__gitsha__` is deprecated as of version 1.2. -Use `__git_commit__` instead. -""" +import os +import time +from importlib.metadata import distribution, version -__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] - -import os.path -from importlib.resources import files - -# obtain version information from the version.cfg file -cp = dict(version="", date="", commit="", timestamp="0") -fcfg = str(files(__name__).joinpath("version.cfg")) -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) - -__version__ = cp["version"] -__date__ = cp["date"] -__git_commit__ = cp["commit"] -__timestamp__ = int(cp["timestamp"]) - -# TODO remove deprecated __gitsha__ in version 1.3. -__gitsha__ = __git_commit__ - -del cp, fcfg, fp, kwords +__date__ = time.ctime(os.path.getctime(distribution("diffpy.pdfgui")._path)) +__version__ = version("diffpy.pdfgui") # End of file