File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 88
99MYDIR = os .path .dirname (os .path .abspath (__file__ ))
1010
11- GIT_MISSING_ERROR_MSG = """
11+ EMSG_GIT_MISSING = """
1212Cannot determine libdiffpy version. Compile from a git repository
1313or use a source archive from
1414
1515 https://github.com/diffpy/libdiffpy/releases
1616"""
1717
18+ EMSG_BAD_FALLBACK_VERSION = """
19+ Inconsistent FALLBACK_VERSION {} vs {} from git tag.
20+ """
21+
1822
1923def gitinfo ():
2024 'Extract dictionary of version data from git records.'
@@ -65,12 +69,13 @@ def getversion():
6569 if gi :
6670 afb = FALLBACK_VERSION
6771 gfb = gi ['version' ].split ('.post' )[0 ] + '.post0'
68- emsg = "Inconsistent FALLBACK_VERSION {!r}. Git tag suggests {!r}."
69- assert gfb == afb , emsg .format (afb , gfb )
72+ if gfb != afb :
73+ raise RuntimeError ( EMSG_BAD_FALLBACK_VERSION .format (afb , gfb ) )
7074 rv .update (gi )
7175 else :
7276 # Not a git repository. Require that gitarchive.cfg is expanded.
73- assert '$Format:' not in ga ['commit' ], GIT_MISSING_ERROR_MSG
77+ if '$Format:' in ga ['commit' ]:
78+ raise RuntimeError (EMSG_GIT_MISSING )
7479 rv ['commit' ] = ga ['commit' ]
7580 rv ['date' ] = ga ['date' ]
7681 # First assume we have an undetermined post-release. Keep version
Original file line number Diff line number Diff line change @@ -5,6 +5,16 @@ import string
55Import ('env' )
66
77
8+ def get_version_or_die ():
9+ from libdiffpybuildutils import getversion
10+ try :
11+ rv = getversion ()
12+ except RuntimeError as e :
13+ print (e )
14+ Exit (1 )
15+ return rv
16+
17+
818def parsemajorminor (hcode ):
919 'Extract major and minor version from a C++ header file.'
1020 mx = re .search (r'(?m)^#define *DIFFPY_VERSION_MAJOR *(\d+)' , hcode )
@@ -69,9 +79,8 @@ vhpp = File('version.hpp')
6979if os .path .isfile (str (vhpp .srcnode ())):
7080 majorminor = parsemajorminor (vhpp .srcnode ().get_contents ())
7181else :
72- from libdiffpybuildutils import getversion
7382 vtpl = File ('version.tpl' )
74- gver = getversion ()
83+ gver = get_version_or_die ()
7584 vhpp , = env .BuildVersionCode (['version.hpp' ], vtpl )
7685 env .Depends (vhpp , env .Value (gver ['version' ] + gver ['commit' ]))
7786 majorminor = (gver ['major' ], gver ['minor' ])
You can’t perform that action at this time.
0 commit comments