Skip to content

Commit 8baba3b

Browse files
authored
Merge pull request #84 from Sparks29032/version
Fix version
2 parents 7ae5330 + 1ff119c commit 8baba3b

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

doc/manual/source/utilities/toolsutility.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Tools Utility
77

88
The ``diffpy.utils.tools`` module provides tool functions for use with diffpy apps.
99

10-
1) ``get_uder_info``: This function is designed for managing and tracking username and email information.
10+
1) ``get_user_info``: This function is designed for managing and tracking username and email information.
1111

12-
Developers can use this function to simplify the process of loading, merging, and saving information consistently and easily.
13-
Additionally, it saves the effort of re-entering information, and allows overriding current information by
14-
passing parameters.
12+
Developers can use this function to simplify the process of loading, merging, and saving information consistently and easily.
13+
Additionally, it saves the effort of re-entering information, and allows overriding current information by
14+
passing parameters.
1515

1616
2) ``get_package_info``: This function loads package name and version information into a dictionary.
17-
It updates the package information under the key "package_info" in the format {"package_name": "version_number"},
18-
resulting in an entry in the passed metadata dictionary that looks like
19-
`{"package_info": {"package1": "version_number1", "package2": "version_number2"} if the function is called more than
20-
once.
17+
It updates the package information under the key "package_info" in the format {"package_name": "version_number"},
18+
resulting in an entry in the passed metadata dictionary that looks like
19+
``{"package_info": {"package1": "version_number1", "package2": "version_number2"}`` if the function is called more than
20+
once.
2121

22-
Users can use these functions to track and manage versions of packages that can later be stored, for example, in an output
23-
file header.
22+
Users can use these functions to track and manage versions of packages that can later be stored, for example, in an output
23+
file header.

src/diffpy/utils/version.py

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,14 @@
1313
#
1414
##############################################################################
1515

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

19-
Notes
20-
-----
21-
Variable `__gitsha__` is deprecated as of version 3.0.
22-
Use `__git_commit__` instead.
23-
"""
18+
# We do not use the other three variables, but can be added back if needed.
19+
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
2420

25-
__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
21+
# obtain version information
22+
from importlib.metadata import version
2623

27-
import os.path
28-
from importlib.resources import as_file, files
29-
30-
# obtain version information from the version.cfg file
31-
cp = dict(version="", date="", commit="", timestamp="0")
32-
if __package__ is not None:
33-
ref = files(__package__) / "version.cfg"
34-
with as_file(ref) as fcfg:
35-
if not os.path.isfile(fcfg): # pragma: no cover
36-
from warnings import warn
37-
38-
warn("Package metadata not found.")
39-
fcfg = os.devnull
40-
with open(fcfg) as fp:
41-
kwords = [
42-
[w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line
43-
]
44-
assert all(w[0] in cp for w in kwords), "received unrecognized keyword"
45-
cp.update(kwords)
46-
del kwords
47-
48-
__version__ = cp["version"]
49-
__date__ = cp["date"]
50-
__git_commit__ = cp["commit"]
51-
__timestamp__ = int(cp["timestamp"])
52-
53-
# TODO remove deprecated __gitsha__ in version 3.1.
54-
__gitsha__ = __git_commit__
55-
56-
del cp
24+
__version__ = version("diffpy.utils")
5725

5826
# End of file

0 commit comments

Comments
 (0)