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

fix variable name bug and synchronize with other ported Install.py files

parent 7ccb0d37
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
# install.pa tool to setup the kim-api library # install.pa tool to setup the kim-api library
# used to automate the steps described in the README file in this dir # used to automate the steps described in the README file in this dir
from __future__ import print_function from __future__ import print_function
import sys,os,re,urllib,subprocess import sys,os,re,subprocess
try: from urllib.request import urlretrieve as geturl
except: from urllib import urlretrieve as geturl
help = """ help = """
Syntax from src dir: make lib-kim args="-v version -b kim-install-dir kim-name -a kim-name" Syntax from src dir: make lib-kim args="-v version -b kim-install-dir kim-name -a kim-name"
...@@ -97,10 +99,10 @@ if buildflag: ...@@ -97,10 +99,10 @@ if buildflag:
# configure LAMMPS to use kim-api to be installed # configure LAMMPS to use kim-api to be installed
with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile: with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile:
mkfle.write("KIM_INSTALL_DIR=%s\n\n" % dir) mkfile.write("KIM_INSTALL_DIR=%s\n\n" % dir)
mkfle.write(".DUMMY: print_dir\n\n") mkfile.write(".DUMMY: print_dir\n\n")
mkfle.write("print_dir:\n") mkfile.write("print_dir:\n")
mkfle.write(" @printf $(KIM_INSTALL_DIR)\n") mkfile.write(" @printf $(KIM_INSTALL_DIR)\n")
with open("%s/Makefile.KIM_Config" % thisdir, 'w') as cfgfile: with open("%s/Makefile.KIM_Config" % thisdir, 'w') as cfgfile:
cfgfile.write("include %s/lib/kim-api/Makefile.KIM_Config" % dir) cfgfile.write("include %s/lib/kim-api/Makefile.KIM_Config" % dir)
...@@ -113,27 +115,23 @@ if buildflag: ...@@ -113,27 +115,23 @@ if buildflag:
print("Downloading kim-api tarball ...") print("Downloading kim-api tarball ...")
try: urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,version)) try: geturl(url,"%s/%s.tgz" % (thisdir,version))
except: except:
cmd = "wget %s %s/%s.tgz" % (url,thisdir,version) cmd = "wget %s %s/%s.tgz" % (url,thisdir,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if not os.path.isfile("%s/%s.tgz" % (thisdir,version)): if not os.path.isfile("%s/%s.tgz" % (thisdir,version)):
print("Both urllib.urlretrieve() and wget command failed to download") print("Both urllib and wget command failed to download")
sys.exit() sys.exit()
print("Unpacking kim-api tarball ...") print("Unpacking kim-api tarball ...")
cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (thisdir,version,version) cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (thisdir,version,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
if txt[0] != 0: error()
# configure kim-api # configure kim-api
print("Configuring kim-api ...") print("Configuring kim-api ...")
cmd = "cd %s/%s; ./configure --prefix='%s'" % (thisdir,version,dir) cmd = "cd %s/%s; ./configure --prefix='%s'" % (thisdir,version,dir)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
# build kim-api # build kim-api
...@@ -145,36 +143,26 @@ if buildflag: ...@@ -145,36 +143,26 @@ if buildflag:
print("configuring all OpenKIM models, this will take a while ...") print("configuring all OpenKIM models, this will take a while ...")
cmd = "cd %s/%s; make add-examples; make add-%s" % \ cmd = "cd %s/%s; make add-examples; make add-%s" % \
(thisdir,version,modelname) (thisdir,version,modelname)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
print("Building kim-api ...") print("Building kim-api ...")
cmd = "cd %s/%s; make" % (thisdir,version) cmd = "cd %s/%s; make" % (thisdir,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
# install kim-api # install kim-api
print("Installing kim-api ...") print("Installing kim-api ...")
cmd = "cd %s/%s; make install" % (thisdir,version) cmd = "cd %s/%s; make install" % (thisdir,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
cmd = "cd %s/%s; make install-set-default-to-v1" %(thisdir,version) cmd = "cd %s/%s; make install-set-default-to-v1" %(thisdir,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
# remove source files # remove source files
print("Removing kim-api source and build files ...") print("Removing kim-api source and build files ...")
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" % (thisdir,version,version) cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" % (thisdir,version,version)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
# add a single model (and possibly its driver) to existing KIM installation # add a single model (and possibly its driver) to existing KIM installation
...@@ -187,7 +175,7 @@ if addflag: ...@@ -187,7 +175,7 @@ if addflag:
error() error()
else: else:
cmd = "cd %s; make -f Makefile.KIM_DIR print_dir" % thisdir cmd = "cd %s; make -f Makefile.KIM_DIR print_dir" % thisdir
dir = subprocess.getstatusoutput(cmd)[1] dir = subprocess.check_output(cmd,shell=True)[1]
# download single model # download single model
# try first via urllib # try first via urllib
...@@ -197,10 +185,10 @@ if addflag: ...@@ -197,10 +185,10 @@ if addflag:
url = "https://openkim.org/download/%s.tgz" % addmodelname url = "https://openkim.org/download/%s.tgz" % addmodelname
try: urllib.urlretrieve(url,"%s/%s.tgz" % (thisdir,addmodelname)) try: geturl(url,"%s/%s.tgz" % (thisdir,addmodelname))
except: except:
cmd = "wget %s %s/%s.tgz" % (url,thisdir,addmodelname) cmd = "wget %s %s/%s.tgz" % (url,thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) txt = subprocess.check_output(cmd,shell=True)
print(txt[1]) print(txt[1])
if not os.path.isfile("%s/%s.tgz" % (thisdir,addmodelname)): if not os.path.isfile("%s/%s.tgz" % (thisdir,addmodelname)):
print("Both urllib.urlretrieve() and wget command failed to download") print("Both urllib.urlretrieve() and wget command failed to download")
...@@ -208,28 +196,27 @@ if addflag: ...@@ -208,28 +196,27 @@ if addflag:
print("Unpacking item tarball ...") print("Unpacking item tarball ...")
cmd = "cd %s; tar zxvf %s.tgz" % (thisdir,addmodelname) cmd = "cd %s; tar zxvf %s.tgz" % (thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
if txt[0] != 0: error()
print("Building item ...") print("Building item ...")
cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname) cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
firstRunOutput = txt[1] firstRunOutput = txt[1]
if txt[0] != 0: if txt[0] != 0:
# Error: but first, check to see if it needs a driver # Error: but first, check to see if it needs a driver
cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname) cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) txt = subprocess.check_output(cmd,shell=True)
if txt[1] == "ParameterizedModel": if txt[1] == "ParameterizedModel":
# Get and install driver # Get and install driver
cmd = "cd %s/%s; make model-driver-name" % (thisdir,addmodelname) cmd = "cd %s/%s; make model-driver-name" % (thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) txt = subprocess.check_output(cmd,shell=True)
adddrivername = txt[1] adddrivername = txt[1]
print("First Installing model driver: %s" % adddrivername) print("First Installing model driver: %s" % adddrivername)
cmd = "cd %s; python Install.py -a %s" % (thisdir,adddrivername) cmd = "cd %s; python Install.py -a %s" % (thisdir,adddrivername)
txt = subprocess.getstatusoutput(cmd) txt = subprocess.check_output(cmd,shell=True)
if txt[0] != 0: if txt[0] != 0:
print(firstRunOutput) print(firstRunOutput)
print(txt[1]) print(txt[1])
...@@ -237,7 +224,7 @@ if addflag: ...@@ -237,7 +224,7 @@ if addflag:
else: else:
print(txt[1]) print(txt[1])
cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname) cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname)
txt = subprocess.getstatusoutput(cmd) txt = subprocess.check_output(cmd,shell=True)
print(txt[1]) print(txt[1])
if txt[0] != 0: if txt[0] != 0:
error() error()
...@@ -251,6 +238,5 @@ if addflag: ...@@ -251,6 +238,5 @@ if addflag:
print(firstRunOutput) print(firstRunOutput)
print("Removing kim item source and build files ...") print("Removing kim item source and build files ...")
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname) cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname)
txt = subprocess.getstatusoutput(cmd) subprocess.check_output(cmd,shell=True)
print(txt[1])
if txt[0] != 0: error()
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