diff --git a/pyproject.toml b/pyproject.toml index 273ea25e..f1926b11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,9 @@ classifiers = [ 'Topic :: Scientific/Engineering :: Chemistry', ] +[project.scripts] +pdfgui = "diffpy.pdfgui.applications.pdfgui:main" + [project.urls] Homepage = "https://github.com/diffpy/diffpy.pdfgui/" Issues = "https://github.com/diffpy/diffpy.pdfgui/issues/" 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