# TODO#!/usr/bin/env python """ Install.py tool to download, compile, and setup the pace library used to automate the steps described in the README file in this dir """ from __future__ import print_function import sys, subprocess from argparse import ArgumentParser sys.path.append('..') from install_helpers import fullpath, geturl, checkmd5sum # settings thisdir = fullpath('.') version = 'v.2021.10.25.fix2' # known checksums for different PACE versions. used to validate the download. checksums = { \ 'v.2021.2.3.upd2' : '8fd1162724d349b930e474927197f20d', 'v.2021.4.9' : '4db54962fbd6adcf8c18d46e1798ceb5', 'v.2021.9.28' : 'f98363bb98adc7295ea63974738c2a1b', 'v.2021.10.25' : 'a2ac3315c41a1a4a5c912bcb1bc9c5cc', 'v.2021.10.25.fix': 'e0572de57039d4afedefb25707b6ceae', 'v.2021.10.25.fix2': '32394d799bc282bb57696c78c456e64f' } parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script")
homepath = "." buildflag = False pathflag = False suffixflag = False linkflag = True 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) homepath = fullpath(homepath) homedir = "%s/plumed2" % (homepath) if (pathflag):
"--path", help="specify folder of existing Eigen installation") parser.add_argument( "-v", "--version", default=version, help="set version of Eigen to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) homepath = fullpath(".") eigenpath = os.path.join(homepath, "eigen3") buildflag = args.build pathflag = args.path is not None version = args.version if pathflag: eigenpath = args.path if not os.path.isdir(eigenpath): sys.exit("Eigen path %s does not exist" % eigenpath) eigenpath = fullpath(eigenpath) # download and unpack Eigen tarball # use glob to find name of dir it unpacks to
"suffix of a Makefile.lammps.* file used for linking LAMMPS with this library" ) parser.add_argument( "-v", "--version", default=version, help="set version of LATTE to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) homepath = fullpath(".") buildflag = args.build pathflag = args.path is not None version = args.version suffixflag = args.machine is not None suffix = args.machine if pathflag: lattedir = args.path if not os.path.isdir(lattedir): sys.exit("LATTE path %s does not exist" % lattedir) lattedir = fullpath(lattedir) homedir = "LATTE-%s" % version
help="specify folder of existing ScaFaCoS installation") parser.add_argument("-v", "--version", default=version, help="set version of ScaFaCoS to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None version = args.version homepath = fullpath(".") scafacospath = os.path.join(homepath, "scafacos-%s" % version) if pathflag: scafacospath = args.path if not os.path.isdir(os.path.join(scafacospath, "include")): sys.exit("ScaFaCoS include path for %s does not exist" % scafacospath) if (not os.path.isdir(os.path.join(scafacospath, "lib64"))) \ and (not os.path.isdir(os.path.join(scafacospath, "lib"))): sys.exit("ScaFaCoS lib path for %s does not exist" % scafacospath) scafacospath = fullpath(scafacospath) # download and unpack ScaFaCoS tarball if buildflag: print("Downloading ScaFaCoS ...")
parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None mscgpath = args.path msuffix = args.machine mscgver = args.version # settings url = "https://github.com/uchicago-voth/MSCG-release/archive/%s.tar.gz" % mscgver tarname = "MS-CG-%s.tar.gz" % mscgver tardir = "MSCG-release-%s" % mscgver homepath = fullpath('.') homedir = os.path.join(homepath, tardir) if pathflag: if not os.path.isdir(mscgpath): sys.exit("MS-CG path %s does not exist" % mscgpath) homedir = fullpath(mscgpath) # download and unpack MS-CG tarfile if buildflag: print("Downloading MS-CG ...") tarname = os.path.join(homepath, tarname) geturl(url, tarname) print("Unpacking MS-CG tarfile ...")
pgroup = parser.add_mutually_exclusive_group() pgroup.add_argument("-b", "--build", action="store_true", help="download and build the Eigen3 library") pgroup.add_argument("-p", "--path", help="specify folder of existing Eigen installation") parser.add_argument("-v", "--version", default=version, help="set version of Eigen to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) homepath = fullpath(".") eigenpath = os.path.join(homepath, "eigen3") buildflag = args.build pathflag = args.path is not None version = args.version if pathflag: eigenpath = args.path if not os.path.isdir(eigenpath): sys.exit("Eigen path %s does not exist" % eigenpath) eigenpath = fullpath(eigenpath) # download and unpack Eigen tarball # use glob to find name of dir it unpacks to
# print help message and exit, if neither build nor path options are given if not args.mpi and not args.serial: parser.print_help() sys.exit(HELP) mpiflag = args.mpi serialflag = args.serial zmqflag = args.zmq # build CSlib # copy resulting lib to cslib/src/libmessage.a # copy appropriate Makefile.lammps.* to Makefile.lammps print("Building CSlib ...") srcdir = fullpath(os.path.join("cslib", "src")) if mpiflag and zmqflag: cmd = "make -C %s lib_parallel" % srcdir elif mpiflag and not zmqflag: cmd = "make -C %s lib_parallel zmq=no" % srcdir elif not mpiflag and zmqflag: cmd = "make -C %s lib_serial" % srcdir elif not mpiflag and not zmqflag: cmd = "make -C %s lib_serial zmq=no" % srcdir print(cmd) try: txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) print(txt.decode('UTF-8')) except subprocess.CalledProcessError as e:
used to automate the steps described in the README file in this dir """ from __future__ import print_function import sys, os, subprocess, shutil from argparse import ArgumentParser sys.path.append('..') from install_helpers import fullpath, geturl parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script") # settings thisdir = fullpath('.') version = "kim-api-v2-2.0.1" # help message HELP = """ Syntax from src dir: make lib-kim args="-b -v version -a kim-name" or: make lib-kim args="-b -a everything" or: make lib-kim args="-n -a kim-name" or: make lib-kim args="-p /usr/local/open-kim -a kim-name" Syntax from lib dir: python Install.py -b -v version -a kim-name or: python Install.py -b -a everything or: python Install.py -n -a kim-name or: python Install.py -p /usr/local/open-kim -a kim-name Examples:
See the list of all KIM models here: https://openkim.org/kim-items/models/by-model-drivers See the list of example KIM models included by default here: https://openkim.org/kim-api in the "What is in the KIM API source package?" section """ # parse args args = sys.argv[1:] nargs = len(args) if nargs == 0: error(help=help) thisdir = fullpath('.') version = "kim-api-v1.9.5" buildflag = False everythingflag = False addflag = False verboseflag = False pathflag = False iarg = 0 while iarg < len(args): if args[iarg] == "-v": if iarg+2 > len(args): error(help=help) version = args[iarg+1] iarg += 2 elif args[iarg] == "-b":
homepath = "." homedir = version buildflag = False pathflag = False linkflag = True 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) voropath = fullpath(args[iarg+1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 else: error(help=help) homepath = fullpath(homepath) homedir = "%s/%s" % (homepath,version) if (pathflag): if not os.path.isdir(voropath): error("Voro++ path does not exist") homedir = voropath if (buildflag and pathflag):
args = sys.argv[1:] nargs = len(args) if nargs == 0: error(help=help) homepath = "." buildflag = False pathflag = False suffixflag = False linkflag = True iarg = 0 while iarg < nargs: if args[iarg] == "-p": if iarg + 2 > nargs: error(help=help) lattedir = fullpath(args[iarg + 1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 elif args[iarg] == "-m": if iarg + 2 > nargs: error(help=help) suffix = args[iarg + 1] suffixflag = True iarg += 2 elif args[iarg] == "-v": if iarg + 2 > nargs: error(help=help) version = args[iarg + 1] iarg += 2 else:
default=mode, choices=['static', 'shared', 'runtime'], help="set plumed linkage mode: static (default), shared, or runtime") args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None plumedpath = args.path homepath = fullpath('.') homedir = "%s/plumed2" % (homepath) if pathflag: if not os.path.isdir(plumedpath): sys.exit("Plumed2 path %s does not exist" % plumedpath) homedir = fullpath(plumedpath) # download and unpack plumed2 tarball if buildflag: url = "https://github.com/plumed/plumed2/releases/download/v%s/plumed-src-%s.tgz" % ( version, version) filename = "plumed-src-%s.tar.gz" % version print("Downloading plumed ...") geturl(url, filename)
homepath = "." buildflag = True pathflag = False linkflag = True 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) scafacospath = fullpath(args[iarg+1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 else: error(help=help) homepath = fullpath(homepath) homedir = "%s/%s" % (homepath,version) if (pathflag): if not os.path.isdir(scafacospath): error("Scafacos path does not exist") homedir =scafacospath if (buildflag and pathflag):
homepath = "." buildflag = False pathflag = False suffixflag = False linkflag = True 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) homepath = fullpath(homepath) homedir = "%s/plumed2" % (homepath)
"--version", default=version, help="set version of Voro++ to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None voropath = args.path homepath = fullpath(".") homedir = os.path.join(homepath, version) if pathflag: if not os.path.isdir(voropath): sys.exit("Voro++ path %s does not exist" % voropath) homedir = fullpath(voropath) # download and unpack Voro++ tarball if buildflag: print("Downloading Voro++ ...") vorotar = os.path.join(homepath, version) + '.tar.gz' geturl(url, vorotar) # verify downloaded archive integrity via md5 checksum, if known.
help="download and build the LATTE library") pgroup.add_argument("-p", "--path", help="specify folder of existing LATTE installation") parser.add_argument("-m", "--machine", choices=['gfortran', 'ifort', 'linalg', 'serial', 'mpi'], help="suffix of a Makefile.lammps.* file used for linking LAMMPS with this library") parser.add_argument("-v", "--version", default=version, help="set version of LATTE to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) homepath = fullpath(".") buildflag = args.build pathflag = args.path is not None version = args.version suffixflag = args.machine is not None suffix = args.machine if pathflag: lattedir = args.path if not os.path.isdir(lattedir): sys.exit("LATTE path %s does not exist" % lattedir) lattedir = fullpath(lattedir) homedir = "LATTE-%s" % version
parser.add_argument("-m", "--mode", default=mode, choices=['static', 'shared', 'runtime'], help="set plumed linkage mode: static (default), shared, or runtime") args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None plumedpath = args.path mode = args.mode homepath = fullpath('.') homedir = "%s/plumed2" % (homepath) if pathflag: if not os.path.isdir(plumedpath): sys.exit("Plumed2 path %s does not exist" % plumedpath) homedir = fullpath(plumedpath) if not os.path.isdir(os.path.join(homedir, 'include', 'plumed', 'core')): sys.exit("No Plumed2 installation found at %s" % plumedpath) # download and unpack plumed2 tarball if buildflag: url = "https://github.com/plumed/plumed2/releases/download/v%s/plumed-src-%s.tgz" % (version, version) filename = "plumed-src-%s.tar.gz" %version print("Downloading plumed ...")
default=version, choices=checksums.keys(), help="set version of n2p2 to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None n2p2path = args.path homepath = fullpath('.') homedir = "%s/n2p2" % (homepath) if pathflag: if not os.path.isdir(n2p2path): sys.exit("n2p2 path %s does not exist" % n2p2path) homedir = fullpath(n2p2path) if not os.path.isfile(os.path.join(homedir, 'include', 'InterfaceLammps.h')): sys.exit("No n2p2 installation found at %s" % n2p2path) # download and unpack n2p2 tarball if buildflag: url = "https://github.com/CompPhysVienna/n2p2/archive/v%s.tar.gz" % ( version)
used to automate the steps described in the README file in this dir """ from __future__ import print_function import sys, os, subprocess, shutil from argparse import ArgumentParser sys.path.append('..') from install_helpers import fullpath, geturl, checkmd5sum parser = ArgumentParser(prog='Install.py', description="LAMMPS library build wrapper script") # settings thisdir = fullpath('.') version = "2.2.1" # known checksums for different KIM-API versions. used to validate the download. checksums = { \ '2.1.2' : '6ac52e14ef52967fc7858220b208cba5', \ '2.1.3' : '6ee829a1bbba5f8b9874c88c4c4ebff8', \ '2.2.0' : 'e7f944e1593cffd7444679a660607f6c', \ '2.2.1' : 'ae1ddda2ef7017ea07934e519d023dca', \ } # help message HELP = """ Syntax from src dir: make lib-kim args="-b -v version -a kim-name" or: make lib-kim args="-b -a everything"
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 = "." homedir = version buildflag = False pathflag = False linkflag = True 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) voropath = fullpath(args[iarg + 1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 else: error(help=help) homepath = fullpath(homepath) homedir = "%s/%s" % (homepath, version) if (pathflag): if not os.path.isdir(voropath): error("Voro++ path does not exist") homedir = voropath
homepath = "." homedir = "eigen3" buildflag = False pathflag = False linkflag = True 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) eigenpath = fullpath(args[iarg+1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 else: error(help=help) homepath = fullpath(homepath) if (pathflag): if not os.path.isdir(eigenpath): error("Eigen path does not exist") if (buildflag and pathflag): error("Cannot use -b and -p flag at the same time")
help="specify folder of existing Voro++ installation") parser.add_argument("-v", "--version", default=version, help="set version of Voro++ to download and build (default: %s)" % version) args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.build and not args.path: parser.print_help() sys.exit(HELP) buildflag = args.build pathflag = args.path is not None voropath = args.path homepath = fullpath(".") homedir = os.path.join(homepath, version) if pathflag: if not os.path.isdir(voropath): sys.exit("Voro++ path %s does not exist" % voropath) homedir = fullpath(voropath) # download and unpack Voro++ tarball if buildflag: print("Downloading Voro++ ...") vorotar = os.path.join(homepath, version) + '.tar.gz' geturl(url, vorotar) # verify downloaded archive integrity via md5 checksum, if known.
zmqflag = True iarg += 1 else: error(help=help) if (not mpiflag and not serialflag): error("Must use either -m or -s flag") if (mpiflag and serialflag): error("Cannot use -m and -s flag at the same time") # build CSlib # copy resulting lib to cslib/src/libmessage.a # copy appropriate Makefile.lammps.* to Makefile.lammps print("Building CSlib ...") srcdir = fullpath("./cslib/src") if mpiflag and zmqflag: cmd = "cd %s; make lib_parallel" % srcdir elif mpiflag and not zmqflag: cmd = "cd %s; make lib_parallel zmq=no" % srcdir elif not mpiflag and zmqflag: cmd = "cd %s; make lib_serial" % srcdir elif not mpiflag and not zmqflag: cmd = "cd %s; make lib_serial zmq=no" % srcdir print(cmd) try: txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) print(txt.decode('UTF-8')) except subprocess.CalledProcessError as e:
help="set EXTRAMAKE variable in <libname>/Makefile.<machine> to Makefile.lammps.<extramake>") args = parser.parse_args() # print help message and exit, if neither build nor path options are given if not args.machine and not args.extramake: parser.print_help() sys.exit(HELP) machine = args.machine extraflag = not args.extramake suffix = args.extramake # set lib from working dir cwd = fullpath('.') lib = os.path.basename(cwd) # create Makefile.auto as copy of Makefile.machine # reset EXTRAMAKE if requested if not os.path.exists("Makefile.%s" % machine): sys.exit("lib/%s/Makefile.%s does not exist" % (lib, machine)) lines = open("Makefile.%s" % machine, 'r').readlines() fp = open("Makefile.auto", 'w') has_extramake = False for line in lines: words = line.split() if len(words) == 3 and words[0] == "EXTRAMAKE" and words[1] == '=':
homepath = "." homedir = "eigen3" buildflag = False pathflag = False linkflag = True 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) eigenpath = fullpath(args[iarg + 1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 else: error(help=help) homepath = fullpath(homepath) if (pathflag): if not os.path.isdir(eigenpath): error("Eigen path does not exist") if (buildflag and pathflag): error("Cannot use -b and -p flag at the same time")
# print help message and exit, if neither build nor path options are given if not args.machine and not args.extramake: parser.print_help() sys.exit(HELP) machine = args.machine extraflag = args.extramake if extraflag: suffix = args.extramake else: suffix = 'empty' # set lib from working dir cwd = fullpath('.') lib = os.path.basename(cwd) # create Makefile.auto as copy of Makefile.machine # reset EXTRAMAKE if requested if not os.path.exists("Makefile.%s" % machine): sys.exit("lib/%s/Makefile.%s does not exist" % (lib, machine)) lines = open("Makefile.%s" % machine, 'r').readlines() fp = open("Makefile.auto", 'w') has_extramake = False for line in lines: words = line.split() if len(words) == 3 and words[0] == "EXTRAMAKE" and words[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) if (pathflag):
args = sys.argv[1:] nargs = len(args) if nargs == 0: error(help=help) homepath = "." buildflag = False pathflag = False suffixflag = False linkflag = True iarg = 0 while iarg < nargs: if args[iarg] == "-p": if iarg+2 > nargs: error(help=help) lattedir = fullpath(args[iarg+1]) pathflag = True iarg += 2 elif args[iarg] == "-b": buildflag = True iarg += 1 elif args[iarg] == "-m": if iarg+2 > nargs: error(help=help) suffix = args[iarg+1] suffixflag = True iarg += 2 elif args[iarg] == "-v": if iarg+2 > nargs: error(help=help) version = args[iarg+1] iarg += 2 else: error(help=help)
See the list of all KIM models here: https://openkim.org/kim-items/models/by-model-drivers See the list of example KIM models included by default here: https://openkim.org/kim-api in the "What is in the KIM API source package?" section """ # parse args args = sys.argv[1:] nargs = len(args) if nargs == 0: error(help=help) thisdir = fullpath('.') version = "kim-api-v1.9.5" buildflag = False everythingflag = False addflag = False verboseflag = False pathflag = False iarg = 0 while iarg < len(args): if args[iarg] == "-v": if iarg + 2 > len(args): error(help=help) version = args[iarg + 1] iarg += 2 elif args[iarg] == "-b":