forked from lijiext/lammps
Further work on lib/kim/install.py
This commit is contained in:
parent
16fc2d6fe1
commit
b0be8b24ea
|
@ -0,0 +1 @@
|
||||||
|
/Makefile.KIM_DIR
|
|
@ -16,11 +16,12 @@
|
||||||
# Settings that the LAMMPS build will import when this package is installed
|
# Settings that the LAMMPS build will import when this package is installed
|
||||||
|
|
||||||
|
|
||||||
|
include ./Makefile.KIM_DIR
|
||||||
|
|
||||||
ifeq ($(wildcard ../../lib/kim/bin/kim-api-build-config),)
|
ifeq ($(wildcard $(KIM_INSTALL_DIR)/bin/kim-api-build-config),)
|
||||||
KIM_CONFIG_HELPER = kim-api-build-config
|
KIM_CONFIG_HELPER = kim-api-build-config
|
||||||
else
|
else
|
||||||
KIM_CONFIG_HELPER = ../../lib/kim/bin/kim-api-build-config
|
KIM_CONFIG_HELPER = $(KIM_INSTALL_DIR)/bin/kim-api-build-config
|
||||||
endif
|
endif
|
||||||
ifeq ($(shell $(KIM_CONFIG_HELPER) --version 2> /dev/null),)
|
ifeq ($(shell $(KIM_CONFIG_HELPER) --version 2> /dev/null),)
|
||||||
$(error $(KIM_CONFIG_HELPER) utility is not available. Something is wrong with your KIM API package setup)
|
$(error $(KIM_CONFIG_HELPER) utility is not available. Something is wrong with your KIM API package setup)
|
||||||
|
|
|
@ -6,10 +6,20 @@
|
||||||
import sys,os,re,urllib,commands
|
import sys,os,re,urllib,commands
|
||||||
|
|
||||||
help = """
|
help = """
|
||||||
Syntax: install.py -v version
|
Syntax: install.py -v version -c kim-dir -b kim-model-name -a kim-name
|
||||||
specify one or more options, order does not matter
|
specify one or more options, order does not matter
|
||||||
-v = version of kim-api to download and work with
|
-v = version of kim-api to download and work with
|
||||||
default = kim-api-v1.8.2 (current as of June 2017)
|
default = kim-api-v1.8.2 (current as of June 2017)
|
||||||
|
-c = create Makefile.KIM_DIR within lammps lib/kim to configure lammps
|
||||||
|
for use with the kim-api library installed at "kim-dir" (absolute
|
||||||
|
path). default = this dir
|
||||||
|
-b = build kim-api and kim model where kim-model-name can be a specific
|
||||||
|
openkim.org model name (such as
|
||||||
|
"EAM_Dynamo_Ackland_W__MO_141627196590_002") or the keyword
|
||||||
|
"OpenKIM" to install all compatible models from the openkim.org
|
||||||
|
site.
|
||||||
|
-a = add kim-name openkim.org item (model driver or model) to existing
|
||||||
|
kim-api instalation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def error():
|
def error():
|
||||||
|
@ -20,53 +30,110 @@ def error():
|
||||||
|
|
||||||
args = sys.argv
|
args = sys.argv
|
||||||
|
|
||||||
dir = "."
|
thisdir = os.environ['PWD']
|
||||||
|
dir = thisdir
|
||||||
version = "kim-api-v1.8.2"
|
version = "kim-api-v1.8.2"
|
||||||
|
|
||||||
|
dirflag = 0
|
||||||
|
buildflag = 0
|
||||||
|
addflag = 0
|
||||||
|
|
||||||
iarg = 1
|
iarg = 1
|
||||||
while iarg < len(args):
|
while iarg < len(args):
|
||||||
if args[iarg] == "-v":
|
if args[iarg] == "-v":
|
||||||
if iarg+2 > len(args): error()
|
if iarg+2 > len(args): error()
|
||||||
version = args[iarg+1]
|
version = args[iarg+1]
|
||||||
iarg += 2
|
iarg += 2
|
||||||
|
elif args[iarg] == "-c":
|
||||||
|
dirflag = 1
|
||||||
|
if iarg+2 > len(args): error()
|
||||||
|
dir = args[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif args[iarg] == "-b":
|
||||||
|
buildflag = 1
|
||||||
|
if iarg+2 > len(args): error()
|
||||||
|
modelname = args[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif args[iarg] == "-a":
|
||||||
|
addflag = 1
|
||||||
|
if iarg+2 > len(args): error()
|
||||||
|
addmodelname = args[iarg+1]
|
||||||
|
iarg += 2
|
||||||
else: error()
|
else: error()
|
||||||
|
|
||||||
|
thisdir = os.path.abspath(thisdir)
|
||||||
dir = os.path.abspath(dir)
|
dir = os.path.abspath(dir)
|
||||||
url = "https://s3.openkim.org/kim-api/%s.tgz" % version
|
url = "https://s3.openkim.org/kim-api/%s.tgz" % version
|
||||||
|
|
||||||
# download and unpack tarball
|
# download and unpack tarball
|
||||||
|
|
||||||
print "Downloading kim-api tarball ..."
|
|
||||||
urllib.urlretrieve(url,"%s/%s.tgz" % (dir,version))
|
|
||||||
print "Unpacking kim-api tarball ..."
|
|
||||||
cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (dir,version,version)
|
|
||||||
txt = commands.getstatusoutput(cmd)
|
|
||||||
if txt[0] != 0: error()
|
|
||||||
|
|
||||||
# configure kim-api
|
if not os.path.isfile("%s/Makefile.KIM_DIR" % thisdir):
|
||||||
print "Configuring kim-api ..."
|
open("%s/Makefile.KIM_DIR" % thisdir, 'w').write("KIM_INSTALL_DIR=%s" % dir)
|
||||||
cmd = "cd %s/%s; ./configure --prefix='%s'" % (dir,version,dir)
|
print "Created %s/Makefile.KIM_DIR : using %s" % (thisdir,dir)
|
||||||
txt = commands.getstatusoutput(cmd)
|
else:
|
||||||
print txt[1]
|
if dirflag == 1:
|
||||||
if txt[0] != 0: error()
|
open("%s/Makefile.KIM_DIR" % thisdir, 'w').write("KIM_INSTALL_DIR=%s" % dir)
|
||||||
|
print "Updated %s/Makefile.KIM_DIR : using %s" % (thisdir,dir)
|
||||||
|
|
||||||
# build kim-api
|
|
||||||
|
|
||||||
print "Building kim-api ..."
|
if buildflag == 1:
|
||||||
cmd = "cd %s/%s; make" % (dir,version)
|
# download kim-api
|
||||||
txt = commands.getstatusoutput(cmd)
|
print "Downloading kim-api tarball ..."
|
||||||
print txt[1]
|
urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,version))
|
||||||
if txt[0] != 0: error()
|
print "Unpacking kim-api tarball ..."
|
||||||
|
cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (thisdir,version,version)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
|
||||||
# install kim-api
|
# configure kim-api
|
||||||
|
print "Configuring kim-api ..."
|
||||||
|
cmd = "cd %s/%s; ./configure --prefix='%s'" % (thisdir,version,dir)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
|
||||||
print "Installing kim-api ..."
|
# build kim-api
|
||||||
cmd = "cd %s/%s; make install" % (dir,version)
|
print "Configuring model : %s" % modelname
|
||||||
txt = commands.getstatusoutput(cmd)
|
cmd = "cd %s/%s; make add-%s" % (thisdir,version,modelname)
|
||||||
print txt[1]
|
txt = commands.getstatusoutput(cmd)
|
||||||
if txt[0] != 0: error()
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
#
|
||||||
|
print "Building kim-api ..."
|
||||||
|
cmd = "cd %s/%s; make" % (thisdir,version)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
|
||||||
cmd = "cd %s/%s; make install-set-default-to-v1" %(dir,version)
|
# install kim-api
|
||||||
txt = commands.getstatusoutput(cmd)
|
print "Installing kim-api ..."
|
||||||
print txt[1]
|
cmd = "cd %s/%s; make install" % (thisdir,version)
|
||||||
if txt[0] != 0: error()
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
#
|
||||||
|
cmd = "cd %s/%s; make install-set-default-to-v1" %(thisdir,version)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
|
||||||
|
# remove source files
|
||||||
|
print "Removing kim-api source and build files"
|
||||||
|
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" % (thisdir,version,version)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
print txt[1]
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
|
||||||
|
if addflag == 1:
|
||||||
|
# download model
|
||||||
|
url = "https://openkim.org/download/%s.tgz" % addmodelname
|
||||||
|
print "Downloading item tarball ..."
|
||||||
|
urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,addmodelname))
|
||||||
|
print "Unpacking item tarball ..."
|
||||||
|
cmd = "cd %s; tar zxvf %s.tgz" % (thisdir,addmodelname)
|
||||||
|
txt = commands.getstatusoutput(cmd)
|
||||||
|
if txt[0] != 0: error()
|
||||||
|
#
|
||||||
|
print "Building item ..."
|
||||||
|
#.....
|
||||||
|
|
Loading…
Reference in New Issue