python3 port, yet untested

This commit is contained in:
Axel Kohlmeyer
2017-07-27 09:25:39 -04:00
parent 0427f6205e
commit acf6d54ec1

View File

@ -4,7 +4,8 @@
# soft linked to by many of the lib/Install.py files # soft linked to by many of the lib/Install.py files
# used to automate the steps described in the corresponding lib/README # used to automate the steps described in the corresponding lib/README
import sys,commands,os from __future__ import print_function
import sys,os,subprocess
# help message # help message
@ -12,7 +13,7 @@ help = """
Syntax from src dir: make lib-libname args="-m machine -e suffix" Syntax from src dir: make lib-libname args="-m machine -e suffix"
Syntax from lib dir: python Install.py -m machine -e suffix Syntax from lib dir: python Install.py -m machine -e suffix
libname = name of lib dir (e.g. atc, colvars, h5md, meam, poems, etc) libname = name of lib dir (e.g. atc, h5md, meam, poems, etc)
specify -m and optionally -e, order does not matter specify -m and optionally -e, order does not matter
-m = peform a clean followed by "make -f Makefile.machine" -m = peform a clean followed by "make -f Makefile.machine"
@ -20,17 +21,17 @@ specify -m and optionally -e, order does not matter
-e = set EXTRAMAKE variable in Makefile.machine to Makefile.lammps.suffix -e = set EXTRAMAKE variable in Makefile.machine to Makefile.lammps.suffix
does not alter existing Makefile.machine does not alter existing Makefile.machine
Examplesx: Examples:
make lib-colvars args="-m g++" # build COLVARS lib with GNU g++ compiler make lib-poems args="-m g++" # build COLVARS lib with GNU g++ compiler
make lib-meam args="-m ifort" # build MEAM lib with Intel ifort compiler make lib-meam args="-m ifort" # build MEAM lib with Intel ifort compiler
""" """
# print error message or help # print error message or help
def error(str=None): def error(str=None):
if not str: print help if not str: print(help)
else: print "ERROR",str else: print("ERROR",str)
sys.exit() sys.exit()
# parse args # parse args
@ -80,12 +81,12 @@ fp.close()
# make the library via Makefile.auto # make the library via Makefile.auto
print "Building lib%s.a ..." % lib print("Building lib%s.a ..." % lib)
cmd = "make -f Makefile.auto clean; make -f Makefile.auto" cmd = "make -f Makefile.auto clean; make -f Makefile.auto"
txt = commands.getoutput(cmd) txt = subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)
print txt print(txt)
if os.path.exists("lib%s.a" % lib): print "Build was successful" if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib)) else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
if not os.path.exists("Makefile.lammps"): if not os.path.exists("Makefile.lammps"):
print "lib/%s/Makefile.lammps was NOT created" % lib print("lib/%s/Makefile.lammps was NOT created" % lib)