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 8
8
9
9
MYDIR = os .path .dirname (os .path .abspath (__file__ ))
10
10
11
- GIT_MISSING_ERROR_MSG = """
11
+ EMSG_GIT_MISSING = """
12
12
Cannot determine libdiffpy version. Compile from a git repository
13
13
or use a source archive from
14
14
15
15
https://github.com/diffpy/libdiffpy/releases
16
16
"""
17
17
18
+ EMSG_BAD_FALLBACK_VERSION = """
19
+ Inconsistent FALLBACK_VERSION {} vs {} from git tag.
20
+ """
21
+
18
22
19
23
def gitinfo ():
20
24
'Extract dictionary of version data from git records.'
@@ -65,12 +69,13 @@ def getversion():
65
69
if gi :
66
70
afb = FALLBACK_VERSION
67
71
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 ) )
70
74
rv .update (gi )
71
75
else :
72
76
# 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 )
74
79
rv ['commit' ] = ga ['commit' ]
75
80
rv ['date' ] = ga ['date' ]
76
81
# 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
5
5
Import ('env' )
6
6
7
7
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
+
8
18
def parsemajorminor (hcode ):
9
19
'Extract major and minor version from a C++ header file.'
10
20
mx = re .search (r'(?m)^#define *DIFFPY_VERSION_MAJOR *(\d+)' , hcode )
@@ -69,9 +79,8 @@ vhpp = File('version.hpp')
69
79
if os .path .isfile (str (vhpp .srcnode ())):
70
80
majorminor = parsemajorminor (vhpp .srcnode ().get_contents ())
71
81
else :
72
- from libdiffpybuildutils import getversion
73
82
vtpl = File ('version.tpl' )
74
- gver = getversion ()
83
+ gver = get_version_or_die ()
75
84
vhpp , = env .BuildVersionCode (['version.hpp' ], vtpl )
76
85
env .Depends (vhpp , env .Value (gver ['version' ] + gver ['commit' ]))
77
86
majorminor = (gver ['major' ], gver ['minor' ])
You can’t perform that action at this time.
0 commit comments