diff --git a/comp.py b/comp.py index 98fd7e8fe85b636497f78644f8460663268bf7d5..becc12012ab1dbc0e8c2870a8fedc5d9e7dc17d9 100755 --- a/comp.py +++ b/comp.py @@ -83,11 +83,13 @@ class CompJob(ParametricJob): TextPRM(self.pars, 'CMAKELIST', 'build options', "%s.cmake" %machineName) YesNoPRM(self.pars, 'DEBUG_MODE', 'debug mode', False) + TextPRM(self.pars, 'PYTHONEXE', 'Python executable', sys.executable) + TextPRM(self.pars, 'NICE_VALUE', 'nice value', "0") TextPRM(self.pars, 'NB_TASKS', 'nb of tasks launched in parallel', "1") TextPRM(self.pars, 'NB_THREADS', 'nb of threads by task', "1") - YesNoPRM(self.pars, 'GIT_FULLCLONE', 'clone the whole repository', False) + YesNoPRM(self.pars, 'GIT_FULLCLONE', 'clone the whole repository', False) TextPRM(self.pars, 'GIT_DEPTH', 'git clone depth', '10') TextPRM(self.pars, 'GIT_BRANCH', 'git branch name', 'master') @@ -102,12 +104,13 @@ class CompJob(ParametricJob): PRMAction(self.actions, 'b', self.pars['ARC_NAME']) PRMAction(self.actions, 'c', self.pars['CMAKELIST']) PRMAction(self.actions, 'd', self.pars['DEBUG_MODE']) + PRMAction(self.actions, 'e', self.pars['PYTHONEXE']) - PRMAction(self.actions, 'e', self.pars['GIT_FULLCLONE']) - PRMAction(self.actions, 'f', self.pars['GIT_DEPTH']) - PRMAction(self.actions, 'g', self.pars['GIT_BRANCH']) + PRMAction(self.actions, 'f', self.pars['GIT_FULLCLONE']) + PRMAction(self.actions, 'g', self.pars['GIT_DEPTH']) + PRMAction(self.actions, 'h', self.pars['GIT_BRANCH']) - PRMAction(self.actions, 'h', self.pars['NICE_VALUE']) + PRMAction(self.actions, 'i', self.pars['NICE_VALUE']) PRMAction(self.actions, 'j', self.pars['NB_TASKS']) PRMAction(self.actions, 'k', self.pars['NB_THREADS']) @@ -193,7 +196,7 @@ class CompJob(ParametricJob): exe='bin/Metafor' dflag='' if self.pars['DEBUG_MODE'].val: - dflag='-D CMAKE_BUILD_TYPE=Debug' + dflag='-DCMAKE_BUILD_TYPE=Debug' # first check if not os.path.isdir('oo_meta'): self.error('oo_meta not here!') @@ -203,6 +206,20 @@ class CompJob(ParametricJob): shutil.rmtree('oo_metaB') os.mkdir('oo_metaB') os.chdir('oo_metaB') + + # which python? + out = subprocess.check_output([self.pars['PYTHONEXE'].val, '-c', + 'from __future__ import print_function; import sys; print(sys.version_info.major)']) + try: + pyver = int(out) + except: + self.error('unable to get python version number') + print('Python version is', pyver) + if pyver==2: + pyflag='-DMETAFOR_USE_PY3=OFF' + else: + pyflag='-DMETAFOR_USE_PY3=ON' + # configure print("configuring oo_meta") cmfile = '../oo_meta/CMake/%s' % self.pars['CMAKELIST'].val @@ -211,8 +228,8 @@ class CompJob(ParametricJob): msg = '%s not found!' % cmfile print(msg) self.mailmsg(msg) - cmd = 'cmake -C %s %s ../oo_meta >autocf.log 2>&1' % (cmfile, dflag) - #print cmd + cmd = 'cmake -C %s %s %s ../oo_meta >autocf.log 2>&1' % (cmfile, pyflag, dflag) + print (cmd) os.system(cmd) # compile ncpu = int(self.pars['NB_TASKS'].val) * int(self.pars['NB_THREADS'].val) @@ -234,14 +251,16 @@ class CompJob(ParametricJob): def cleanBattery(self): os.chdir('oo_metaB/bin') print("cleaning old results") - os.system("python battery.py clean >/dev/null 2>&1") + os.system("%s battery.py clean >/dev/null 2>&1" % self.pars['PYTHONEXE'].val) os.chdir('../..') def startBat(self): now = datetime.datetime.now() print("starting battery at %s (come back tomorrow)" % now.ctime()) os.chdir('oo_metaB/bin') - cmd="nice -%s python battery.py -j %s -k %s >battery.log 2>&1" % (self.pars['NICE_VALUE'].val, self.pars['NB_TASKS'].val, self.pars['NB_THREADS'].val) + cmd="nice -%s %s battery.py -j %s -k %s >battery.log 2>&1" % \ + (self.pars['NICE_VALUE'].val, self.pars['PYTHONEXE'].val, \ + self.pars['NB_TASKS'].val, self.pars['NB_THREADS'].val) p = subprocess.Popen(cmd, shell=True) p.wait() # finish script @@ -252,9 +271,9 @@ class CompJob(ParametricJob): def checkResults(self): # pars indep os.chdir('oo_metaB/bin') - print("diff'ing results") - cmd="python battery.py diff" - print("checkResults: cmd = %s" % cmd) + print ("diff'ing results") + cmd="%s battery.py diff" % self.pars['PYTHONEXE'].val + print ("checkResults: cmd = %s" % cmd) os.system(cmd) file='verif/%s-diffs.html' % machineid() print("verif file name = %s" % file) diff --git a/prmClasses.py b/prmClasses.py index 79eee79afefc6b08d0e0356480a64e6fa6bb7570..1578916a16416947c4274027af2d8cff03569aa6 100644 --- a/prmClasses.py +++ b/prmClasses.py @@ -35,7 +35,7 @@ class PRMSet(object): self.debug = _verb def printPars(self): - for par in self.pars.values(): + for par in list(self.pars.values()): par.writePRM(sys.stdout) def loadPaths(self): @@ -49,7 +49,7 @@ class PRMSet(object): pth = self.savePath() fname = os.path.join(pth, self.cfgfile) file = open(fname,"w") - for par in self.pars.values(): + for par in list(self.pars.values()): par.writePRM(file) file.close()