Skip to content

Commit aeca43d

Browse files
authored
try version fix (#191)
1 parent 9177637 commit aeca43d

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

Diff for: src/diffpy/pdfgui/version.py

+6-34
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,13 @@
1313
#
1414
##############################################################################
1515

16-
"""
17-
Definition of __version__, __date__, __timestamp__, __git_commit__.
16+
"""Definition of __version__ and __date__."""
1817

19-
Notes
20-
-----
21-
Variable `__gitsha__` is deprecated as of version 1.2.
22-
Use `__git_commit__` instead.
23-
"""
18+
import os
19+
import time
20+
from importlib.metadata import distribution, version
2421

25-
__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
26-
27-
import os.path
28-
from importlib.resources import files
29-
30-
# obtain version information from the version.cfg file
31-
cp = dict(version="", date="", commit="", timestamp="0")
32-
fcfg = str(files(__name__).joinpath("version.cfg"))
33-
if not os.path.isfile(fcfg): # pragma: no cover
34-
from warnings import warn
35-
36-
warn("Package metadata not found.")
37-
fcfg = os.devnull
38-
with open(fcfg) as fp:
39-
kwords = [[w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line]
40-
assert all(w[0] in cp for w in kwords), "received unrecognized keyword"
41-
cp.update(kwords)
42-
43-
__version__ = cp["version"]
44-
__date__ = cp["date"]
45-
__git_commit__ = cp["commit"]
46-
__timestamp__ = int(cp["timestamp"])
47-
48-
# TODO remove deprecated __gitsha__ in version 1.3.
49-
__gitsha__ = __git_commit__
50-
51-
del cp, fcfg, fp, kwords
22+
__date__ = time.ctime(os.path.getctime(distribution("diffpy.pdfgui")._path))
23+
__version__ = version("diffpy.pdfgui")
5224

5325
# End of file

0 commit comments

Comments
 (0)