diff --git a/lib/mscg/Install.py b/lib/mscg/Install.py index 5c0164f4a5..ce74ef24d9 100644 --- a/lib/mscg/Install.py +++ b/lib/mscg/Install.py @@ -6,80 +6,76 @@ from __future__ import print_function import sys,os,re,subprocess,shutil sys.path.append('..') -from install_helpers import error,get_cpus,fullpath,which,get_cpus,geturl +from install_helpers import get_cpus,fullpath,get_cpus,geturl + +from argparse import ArgumentParser + +parser = ArgumentParser(prog='Install.py', + description="LAMMPS library build wrapper script") + +# settings + +version = "1.7.3.1" +machine = "g++_simple" # help message help = """ -Syntax from src dir: make lib-mscg args="-p [path] -m [suffix]" +Syntax from src dir: make lib-mscg args="-p [path] -m [suffix] -v [version]" or: make lib-mscg args="-b -m [suffix]" -Syntax from lib dir: python Install.py -p [path] -m [suffix] +Syntax from lib dir: python Install.py -p [path] -m [suffix] -v [version] Syntax from lib dir: python Install.py -b -m [suffix] -specify one or more options, order does not matter - - -b = download and build MS-CG library - -p = specify folder of existing MS-CG installation - -m = machine suffix specifies which src/Make/Makefile.suffix to use - default suffix = g++_simple - Example: -make lib-mscg args="-b -m serial " # download/build in lib/mscg/MSCG-release-master with settings compatible with "make serial" -make lib-mscg args="-b -m mpi " # download/build in lib/mscg/MSCG-release-master with settings compatible with "make mpi" +make lib-mscg args="-b -m serial " # download/build in lib/mscg/MSCG-release with settings compatible with "make serial" +make lib-mscg args="-b -m mpi " # download/build in lib/mscg/MSCG-release with settings compatible with "make mpi" make lib-mscg args="-p /usr/local/mscg-release " # use existing MS-CG installation in /usr/local/mscg-release """ +# known checksums for different MSCG versions. used to validate the download. +checksums = { \ + '1.7.3.1' : '8c45e269ee13f60b303edd7823866a91', \ + } + +# parse and process arguments + +pgroup = parser.add_mutually_exclusive_group() +pgroup.add_argument("-b", "--build", action="store_true", + help="download and build the MSCG library") +pgroup.add_argument("-p", "--path", + help="specify folder of existing MSCG installation") +parser.add_argument("-v", "--version", default=version, choices=checksums.keys(), + help="set version of MSCG to download and build (default: %s)" % version) +parser.add_argument("-m", "--machine", default=machine, choices=['g++_simple','intel_simple','lapack', 'mac'], + help="set machine suffix specifies which src/Make/Makefile.suffix to use. (default: %s)" % machine) + +args = parser.parse_args() + +# print help message and exit, if neither build nor path options are given +if args.build == False and not args.path: + parser.print_help() + sys.exit(help) + +buildflag = args.build +pathflag = args.path != None +mscgpath= args.path +msuffix = args.machine +mscgver = args.version + # settings -mscgver = "1.7.3.1" url = "https://github.com/uchicago-voth/MSCG-release/archive/%s.tar.gz" % mscgver tarfile = "MS-CG-%s.tar.gz" % mscgver tardir = "MSCG-release-%s" % mscgver -# parse args - -args = sys.argv[1:] -nargs = len(args) -if nargs == 0: error(help=help) - -homepath = "." -homedir = tardir - -buildflag = False -pathflag = False -linkflag = True -msuffix = "g++_simple" - -iarg = 0 -while iarg < nargs: - if args[iarg] == "-p": - if iarg+2 > nargs: error(help=help) - mscgpath = fullpath(args[iarg+1]) - pathflag = True - iarg += 2 - elif args[iarg] == "-m": - if iarg+2 > nargs: error(help=help) - msuffix = args[iarg+1] - iarg += 2 - elif args[iarg] == "-b": - buildflag = True - iarg += 1 - else: error(help=help) - -homepath = fullpath(homepath) -homedir = "%s/%s" % (homepath,homedir) +homepath = fullpath('.') +homedir = "%s/%s" % (homepath,tardir) if (pathflag): if not os.path.isdir(mscgpath): error("MS-CG path does not exist") homedir = mscgpath -if (buildflag and pathflag): - error("Cannot use -b and -p flag at the same time") - -if (not buildflag and not pathflag): - error("Have to use either -b or -p flag") - # download and unpack MS-CG tarfile if buildflag: @@ -127,13 +123,12 @@ if buildflag: # create 2 links in lib/mscg to MS-CG src dir -if linkflag: - print("Creating links to MS-CG include and lib files") - if os.path.isfile("includelink") or os.path.islink("includelink"): - os.remove("includelink") - if os.path.isfile("liblink") or os.path.islink("liblink"): - os.remove("liblink") - cmd = 'ln -s "%s/src" includelink' % homedir - subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) - cmd = 'ln -s "%s/src" liblink' % homedir - subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) +print("Creating links to MS-CG include and lib files") +if os.path.isfile("includelink") or os.path.islink("includelink"): + os.remove("includelink") +if os.path.isfile("liblink") or os.path.islink("liblink"): + os.remove("liblink") +cmd = 'ln -s "%s/src" includelink' % homedir +subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) +cmd = 'ln -s "%s/src" liblink' % homedir +subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index fecd565d35..f68041d2d2 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -6,7 +6,16 @@ from __future__ import print_function import sys,os,re,subprocess,hashlib,shutil sys.path.append('..') -from install_helpers import error,get_cpus,fullpath,which,geturl,checkmd5sum +from install_helpers import get_cpus,fullpath,geturl,checkmd5sum +from argparse import ArgumentParser + +parser = ArgumentParser(prog='Install.py', + description="LAMMPS library build wrapper script") + +# settings + +version = "2.4.3" +mode = "static" # help message @@ -19,24 +28,12 @@ Syntax from lib dir: python Install.py -b -v 2.4.3 or: python Install.py -b or: python Install.py -p /usr/local/plumed2 -m shared -specify one or more options, order does not matter - - -b = download and build the plumed2 library - -v = set version of plumed2 to download and build (default: 2.4.3) - -p = specify folder of existing plumed2 installation - -m = set plumed linkage mode: static (default), shared, or runtime - Example: make lib-plumed args="-b" # download/build in lib/plumed/plumed2 make lib-plumed args="-p $HOME/plumed2 -m shared" # use existing Plumed2 installation in $HOME/plumed2 """ -# settings - -version = "2.4.3" -mode = "static" - # known checksums for different PLUMED versions. used to validate the download. checksums = { \ '2.4.2' : '88188743a6e03ef076e5377d03ebb0e7', \ @@ -44,55 +41,36 @@ checksums = { \ '2.5b' : 'e341bdef469be1da058b8a0b97a3db22', \ } -# parse args +# parse and process arguments -args = sys.argv[1:] -nargs = len(args) -if nargs == 0: error(help=help) +pgroup = parser.add_mutually_exclusive_group() +pgroup.add_argument("-b", "--build", action="store_true", + help="download and build the plumed2 library") +pgroup.add_argument("-p", "--path", + help="specify folder of existing plumed2 installation") +parser.add_argument("-v", "--version", default=version, choices=checksums.keys(), + help="set version of plumed to download and build (default: %s)" % version) +parser.add_argument("-m", "--mode", default=mode, choices=['static', 'shared', 'runtime'], + help="set plumed linkage mode: static (default), shared, or runtime") -homepath = "." +args = parser.parse_args() -buildflag = False -pathflag = False -suffixflag = False -linkflag = True +# print help message and exit, if neither build nor path options are given +if args.build == False and not args.path: + parser.print_help() + sys.exit(help) -iarg = 0 -while iarg < nargs: - if args[iarg] == "-v": - if iarg+2 > nargs: error(help=help) - version = args[iarg+1] - iarg += 2 - elif args[iarg] == "-p": - if iarg+2 > nargs: error(help=help) - plumedpath = fullpath(args[iarg+1]) - pathflag = True - iarg += 2 - elif args[iarg] == "-m": - if iarg+2 > nargs: error(help=help) - mode = args[iarg+1] - iarg += 2 - elif args[iarg] == "-b": - buildflag = True - iarg += 1 - else: error(help=help) +buildflag = args.build +pathflag = args.path != None +plumedpath= args.path -homepath = fullpath(homepath) +homepath = fullpath('.') homedir = "%s/plumed2" % (homepath) if (pathflag): if not os.path.isdir(plumedpath): error("Plumed2 path does not exist") homedir = plumedpath -if (buildflag and pathflag): - error("Cannot use -b and -p flag at the same time") - -if (not buildflag and not pathflag): - error("Have to use either -b or -p flag") - -if ((mode != "static") and (mode != "shared") and (mode != "runtime")): - error("Unknown linkage mode '%s' for Plumed" % mode) - # download and unpack plumed2 tarball if buildflag: @@ -128,18 +106,17 @@ if buildflag: # create 2 links in lib/plumed to plumed2 installation dir -if linkflag: - print("Creating links to plumed2 include and lib files") - if os.path.isfile("includelink") or os.path.islink("includelink"): - os.remove("includelink") - if os.path.isfile("liblink") or os.path.islink("liblink"): - os.remove("liblink") - cmd = 'ln -s "%s/include" includelink' % homedir +print("Creating links to plumed2 include and lib files") +if os.path.isfile("includelink") or os.path.islink("includelink"): + os.remove("includelink") +if os.path.isfile("liblink") or os.path.islink("liblink"): + os.remove("liblink") +cmd = 'ln -s "%s/include" includelink' % homedir +subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) +cmd = 'ln -s "%s/lib" liblink' % homedir +subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) +if os.path.isfile("Makefile.lammps.%s" % mode): + print("Creating Makefile.lammps") + cmd = 'echo PLUMED_LIBDIR="%s/lib" > Makefile.lammps; cat liblink/plumed/src/lib/Plumed.inc.%s Makefile.lammps.%s >> Makefile.lammps' % (homedir,mode,mode) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) - cmd = 'ln -s "%s/lib" liblink' % homedir - subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) - if os.path.isfile("Makefile.lammps.%s" % mode): - print("Creating Makefile.lammps") - cmd = 'echo PLUMED_LIBDIR="%s/lib" > Makefile.lammps; cat liblink/plumed/src/lib/Plumed.inc.%s Makefile.lammps.%s >> Makefile.lammps' % (homedir,mode,mode) - subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index 4f906cf6f2..b76ef42806 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -23,6 +23,7 @@ help = """ Syntax from src dir: make lib-voronoi args="-b" or: make lib-voronoi args="-p /usr/local/voro++-0.4.6" or: make lib-voronoi args="-b -v voro++-0.4.6" + Syntax from lib dir: python Install.py -b -v voro++-0.4.6 or: python Install.py -b or: python Install.py -p /usr/local/voro++-0.4.6 @@ -41,7 +42,7 @@ pgroup.add_argument("-b", "--build", action="store_true", pgroup.add_argument("-p", "--path", help="specify folder of existing Voro++ installation") parser.add_argument("-v", "--version", default=version, - help="set Voro++ version of Voro++ to download and build (default: %s)" % version) + help="set version of Voro++ to download and build (default: %s)" % version) args = parser.parse_args() @@ -53,7 +54,6 @@ if args.build == False and not args.path: buildflag = args.build pathflag = args.path != None voropath = args.path -linkflag = True homepath = fullpath(".") homedir = "%s/%s" % (homepath,version)