Skip to content

Commit dd3f60d

Browse files
committed
Merge branch 'common-diffpy-patches'.
2 parents 67409c7 + f98e9f0 commit dd3f60d

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

.coveragerc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ exclude_lines =
66
## Have to re-enable the standard pragma
77
pragma: no cover
88
## Don't complain if tests don't hit defensive assertion code:
9-
# raise AssertionError
10-
# raise NotImplementedError
9+
raise AssertionError
10+
raise NotImplementedError
11+
^[ ]*assert False
1112

1213
## Don't complain if non-runnable code isn't run:
1314
^[ ]{4}unittest.main()
15+
if __name__ == .__main__.:
1416

1517

1618
[run]

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ before_install:
8484
- $NOBREW || brew install scons
8585
- $NOBREW || brew install python3
8686
- $NOBREW || brew install boost-python --with-python3
87-
- $NOBREW || brew tap homebrew/python
87+
- $NOBREW || brew install gcc || brew link --overwrite gcc
8888
- $NOBREW || brew install numpy --without-python --with-python3
8989

9090
- $NOSYS || devutils/makesdist
@@ -107,7 +107,7 @@ install:
107107
- $NOSYS || $MYPIP install $MYPIPFLAGS "${MYTARBUNDLE}"
108108

109109
- cd ${MYRUNDIR}
110-
- MYGIT_REV=$($MYPYTHON -c "import ${MYNAME}.version as v; print(v.__gitsha__)")
110+
- MYGIT_REV=$($MYPYTHON -c "import ${MYNAME}.version as v; print(v.__git_commit__)")
111111
- if [[ "${TRAVIS_COMMIT}" != "${MYGIT_REV}" ]]; then
112112
echo "Version mismatch ${TRAVIS_COMMIT} vs ${MYGIT_REV}.";
113113
exit 1;

src/pyobjcryst/version.py

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

16+
"""
17+
Definition of __version__, __date__, __timestamp__, __git_commit__,
18+
libobjcryst_version_info.
1619
17-
"""Definition of __version__, __date__, __gitsha__, libobjcryst_version_info.
20+
Notes
21+
-----
22+
Variable `__gitsha__` is deprecated as of version 2.1.
23+
Use `__git_commit__` instead.
1824
"""
1925

26+
__all__ = ['__date__', '__git_commit__', '__timestamp__', '__version__',
27+
'libobjcryst_version_info']
28+
29+
import os.path
30+
2031
from pkg_resources import resource_filename
2132

22-
import sys
23-
if sys.version_info[0] >= 3:
24-
from configparser import RawConfigParser
25-
else:
26-
from ConfigParser import RawConfigParser
27-
del sys
2833

2934
# obtain version information from the version.cfg file
30-
cp = RawConfigParser(dict(version='', date='', commit='', timestamp=0))
31-
if not cp.read(resource_filename(__name__, 'version.cfg')):
35+
cp = dict(version='', date='', commit='', timestamp='0')
36+
fcfg = resource_filename(__name__, 'version.cfg')
37+
if not os.path.isfile(fcfg): # pragma: no cover
3238
from warnings import warn
3339
warn('Package metadata not found, execute "./setup.py egg_info".')
40+
fcfg = os.devnull
41+
with open(fcfg) as fp:
42+
kwords = [[w.strip() for w in line.split(' = ', 1)]
43+
for line in fp if line[:1].isalpha() and ' = ' in line]
44+
assert all(w[0] in cp for w in kwords), "received unrecognized keyword"
45+
cp.update(kwords)
46+
47+
__version__ = cp['version']
48+
__date__ = cp['date']
49+
__git_commit__ = cp['commit']
50+
__timestamp__ = int(cp['timestamp'])
3451

35-
__version__ = cp.get('DEFAULT', 'version')
36-
__date__ = cp.get('DEFAULT', 'date')
37-
__gitsha__ = cp.get('DEFAULT', 'commit')
38-
__timestamp__ = cp.getint('DEFAULT', 'timestamp')
52+
# TODO remove deprecated __gitsha__ in version 2.2.
53+
__gitsha__ = __git_commit__
3954

40-
del cp
55+
del cp, fcfg, fp, kwords
4156

4257
# version information on the active libObjCryst library ----------------------
4358

0 commit comments

Comments
 (0)