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

restore python3 support. this now can run with python 2.7.13 and 3.5.3.

parent ec42a605
No related branches found
No related tags found
No related merge requests found
...@@ -87,14 +87,15 @@ url = "https://s3.openkim.org/kim-api/%s.tgz" % version ...@@ -87,14 +87,15 @@ url = "https://s3.openkim.org/kim-api/%s.tgz" % version
if buildflag: if buildflag:
# set install directory # set install directory
dir = os.path.join(os.path.abspath(dir), "installed-" + version) dir = os.path.join(os.path.abspath(dir), "installed-" + version)
# check to see if an installed kim-api already exists # check to see if an installed kim-api already exists and wipe it out.
if os.path.isdir(dir): if os.path.isdir(dir):
print("kim-api is already installed at %s" % dir) print("kim-api is already installed at %s.\nRemoving it for re-install" % dir)
print("Must remove this directory in order to resintall at this location") cmd = "rm -rf %s" % dir
sys.exit() subprocess.check_output(cmd,shell=True)
# configure LAMMPS to use kim-api to be installed # configure LAMMPS to use kim-api to be installed
...@@ -110,19 +111,9 @@ if buildflag: ...@@ -110,19 +111,9 @@ if buildflag:
print("Created %s/Makefile.KIM_DIR : using %s" % (thisdir,dir)) print("Created %s/Makefile.KIM_DIR : using %s" % (thisdir,dir))
# download entire kim-api tarball # download entire kim-api tarball
# try first via urllib
# if fails (probably due to no SSL support), use wget
print("Downloading kim-api tarball ...") print("Downloading kim-api tarball ...")
geturl(url,"%s/%s.tgz" % (thisdir,version))
try: geturl(url,"%s/%s.tgz" % (thisdir,version))
except:
cmd = "wget %s %s/%s.tgz" % (url,thisdir,version)
subprocess.check_output(cmd,shell=True)
if not os.path.isfile("%s/%s.tgz" % (thisdir,version)):
print("Both urllib and wget command failed to download")
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)
subprocess.check_output(cmd,shell=True) subprocess.check_output(cmd,shell=True)
...@@ -182,17 +173,8 @@ if addflag: ...@@ -182,17 +173,8 @@ if addflag:
# if fails (probably due to no SSL support), use wget # if fails (probably due to no SSL support), use wget
print("Downloading item tarball ...") print("Downloading item tarball ...")
url = "https://openkim.org/download/%s.tgz" % addmodelname url = "https://openkim.org/download/%s.tgz" % addmodelname
geturl(url,"%s/%s.tgz" % (thisdir,addmodelname))
try: geturl(url,"%s/%s.tgz" % (thisdir,addmodelname))
except:
cmd = "wget %s %s/%s.tgz" % (url,thisdir,addmodelname)
txt = subprocess.check_output(cmd,shell=True)
print(txt[1])
if not os.path.isfile("%s/%s.tgz" % (thisdir,addmodelname)):
print("Both urllib.urlretrieve() and wget command failed to download")
sys.exit()
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)
...@@ -205,19 +187,19 @@ if addflag: ...@@ -205,19 +187,19 @@ if addflag:
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
# Error: but first, check to see if it needs a driver # Error: but first, check to see if it needs a driver
firstRunOutput = e.output.decode()
firstRunOutput = e.output
cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname) cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname)
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
txt = txt.decode().strip()
if txt == "ParameterizedModel": if txt == "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.check_output(cmd,stderr=subprocess.STDOUT,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
adddrivername = txt adddrivername = txt.decode().strip()
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)
try: try:
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
...@@ -225,17 +207,16 @@ if addflag: ...@@ -225,17 +207,16 @@ if addflag:
print(e.output) print(e.output)
sys.exit() sys.exit()
print(txt)
# now install the model that needed the driver # now install the model that needed the driver
print("Now installing model : %s" % addmodelname)
cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname) cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname)
try: try:
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(e.output) print(e.output)
sys.exit() sys.exit()
print(txt) print(txt.decode())
sys.exit() sys.exit()
else: else:
print(firstRunOutput) print(firstRunOutput)
......
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