From 33c2855cdf3c9cffabf4b5046d7ad3fa8a42bfd4 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 26 Oct 2006 18:40:05 +0000 Subject: [PATCH] *** empty log message *** --- tools/src/sundials_version.py | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/src/sundials_version.py diff --git a/tools/src/sundials_version.py b/tools/src/sundials_version.py new file mode 100644 index 000000000..0af19e049 --- /dev/null +++ b/tools/src/sundials_version.py @@ -0,0 +1,45 @@ +# +# find the version of the installed sundials package +# +import string +import sys +args = sys.argv + +def splitversion(s): + toks = s.split('.') + if len(toks) <> 3: + return (0,0,0) + return (string.atoi(toks[0]), string.atoi(toks[1]), string.atoi(toks[2])) + +sundials_home = args[1] +vinst = (0,0,0) + +try: + readme = open(sundials_home+'/README','r') +except: + print "can't open "+sundials_home+"/README" + sys.exit(-1) + +try: + lines = readme.readlines() + for line in lines: + toks = line.split() + if 'Release' in toks: + n = toks.index('Release') + version = toks[n+1] + if version[-1] == ',': + version = version[:-1] + vinst = splitversion(version) + break +except: + vinst = (-1,-1,-1) + +fout = open('sundials_includes.h','w') +fout.write('#define SUNDIALS_MAJOR_VERSION = '+`vinst[0]`+'\n#define SUNDIALS_MINOR_VERSION = '+`vinst[1]`+'\n#define SUNDIALS_REVISION = '+`vinst[2]`) + +fout.write('\n#define SUNDIALS_VERSION_'+`vinst[0]`+'\n') + +fout.close() + + +