Skip to content
Snippets Groups Projects
Commit acf6d54e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

python3 port, yet untested

parent 0427f620
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ ...@@ -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 = """ ...@@ -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 ...@@ -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
...@@ -47,12 +48,12 @@ while iarg < nargs: ...@@ -47,12 +48,12 @@ while iarg < nargs:
if args[iarg] == "-m": if args[iarg] == "-m":
if iarg+2 > nargs: error() if iarg+2 > nargs: error()
machine = args[iarg+1] machine = args[iarg+1]
iarg += 2 iarg += 2
elif args[iarg] == "-e": elif args[iarg] == "-e":
if iarg+2 > nargs: error() if iarg+2 > nargs: error()
extraflag = 1 extraflag = 1
suffix = args[iarg+1] suffix = args[iarg+1]
iarg += 2 iarg += 2
else: error() else: error()
# set lib from working dir # set lib from working dir
...@@ -62,7 +63,7 @@ lib = os.path.basename(cwd) ...@@ -62,7 +63,7 @@ lib = os.path.basename(cwd)
# create Makefile.auto as copy of Makefile.machine # create Makefile.auto as copy of Makefile.machine
# reset EXTRAMAKE if requested # reset EXTRAMAKE if requested
if not os.path.exists("Makefile.%s" % machine): if not os.path.exists("Makefile.%s" % machine):
error("lib/%s/Makefile.%s does not exist" % (lib,machine)) error("lib/%s/Makefile.%s does not exist" % (lib,machine))
...@@ -80,12 +81,12 @@ fp.close() ...@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment