Skip to content

Commit c396974

Browse files
committed
__init__.py, version.py
1 parent f0c1f6b commit c396974

File tree

2 files changed

+25
-60
lines changed

2 files changed

+25
-60
lines changed

src/diffpy/labpdfproc/__init__.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
#!/usr/bin/env python
22
##############################################################################
33
#
4-
# diffpy by DANSE Diffraction group
5-
# Simon J. L. Billinge
6-
# (c) 2010 The Trustees of Columbia University
7-
# in the City of New York. All rights reserved.
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
86
#
9-
# File coded by: Pavol Juhas
7+
# File coded by: Billinge Group members and community contributors.
108
#
11-
# See AUTHORS.txt for a list of people who contributed.
12-
# See LICENSE_DANSE.txt for license information.
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
1515

16-
"""diffpy - tools for structure analysis by diffraction.
17-
18-
Blank namespace package.
19-
"""
20-
21-
22-
from pkgutil import extend_path
16+
"""Tools for processing x-ray powder diffraction data from laboratory sources"""
2317

24-
__path__ = extend_path(__path__, __name__)
18+
# package version
19+
from diffpy.labpdfproc.version import __version__
2520

21+
# silence the pyflakes syntax checker
22+
assert __version__ or True
2623

2724
# End of file

src/diffpy/labpdfproc/version.py

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,26 @@
11
#!/usr/bin/env python
22
##############################################################################
33
#
4-
# diffpy.utils by DANSE Diffraction group
5-
# Simon J. L. Billinge
6-
# (c) 2011 The Trustees of Columbia University
7-
# in the City of New York. All rights reserved.
4+
# (c) 2024 The Trustees of Columbia University in the City of New York.
5+
# All rights reserved.
86
#
9-
# File coded by: Pavol Juhas
7+
# File coded by: Billinge Group members and community contributors.
108
#
11-
# See AUTHORS.txt for a list of people who contributed.
12-
# See LICENSE_DANSE.txt for license information.
9+
# See GitHub contributions for a more detailed list of contributors.
10+
# https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors
11+
#
12+
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
1515

16-
"""
17-
Definition of __version__, __date__, __timestamp__, __git_commit__.
18-
19-
Notes
20-
-----
21-
Variable `__gitsha__` is deprecated as of version 3.0.
22-
Use `__git_commit__` instead.
23-
"""
24-
25-
__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
26-
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
16+
"""Definition of __version__."""
4717

48-
__version__ = cp["version"]
49-
__date__ = cp["date"]
50-
__git_commit__ = cp["commit"]
51-
__timestamp__ = int(cp["timestamp"])
18+
# We do not use the other three variables, but can be added back if needed.
19+
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
5220

53-
# TODO remove deprecated __gitsha__ in version 3.1.
54-
__gitsha__ = __git_commit__
21+
# obtain version information
22+
from importlib.metadata import version
5523

56-
del cp
24+
__version__ = version("diffpy.labpdfproc")
5725

5826
# End of file

0 commit comments

Comments
 (0)