Skip to content

Commit

Permalink
try version fix (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieqiong authored Aug 21, 2024
1 parent 9177637 commit aeca43d
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions src/diffpy/pdfgui/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aeca43d

Please sign in to comment.