Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
multiscale
lammps
Commits
84065dde
Commit
84065dde
authored
7 years ago
by
Ryan S. Elliott
Browse files
Options
Downloads
Patches
Plain Diff
Refactor lib/kim/Install.py; works with phtyon 3 2.7
parent
355aad96
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/kim/Install.py
+54
-46
54 additions, 46 deletions
lib/kim/Install.py
with
54 additions
and
46 deletions
lib/kim/Install.py
+
54
−
46
View file @
84065dde
#!/usr/bin/env python
#!/usr/bin/env python
# install.p
a
tool to setup the kim-api library
# install.p
y
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
,
subprocess
import
sys
,
os
,
re
,
subprocess
...
@@ -8,28 +8,25 @@ try: from urllib.request import urlretrieve as geturl
...
@@ -8,28 +8,25 @@ try: from urllib.request import urlretrieve as geturl
except
:
from
urllib
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 -a kim-name
"
Syntax from lib dir: python Install.py -v version -b
kim-install-dir kim-name
-a kim-name
Syntax from lib dir: python Install.py -v version -b -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 library to use
-v = version of KIM API library to use
default = kim-api-v1.8.2 (current as of June 2017)
default = kim-api-v1.8.2 (current as of June 2017)
-b = download and build KIM API library with KIM models
-b = download and build KIM API library with example Models
kim-dir = where to install/build the KIM API library
use
"
.
"
to install in lib/kim
kim-name = none to install only the example KIM models
kim-name = KIM model name (see example below) + examples
kim-name = OpenKIM to install all models
from the openkim.org site (this can take 30 minutes or more)
-a = add single KIM model or model driver with kim-name
-a = add single KIM model or model driver with kim-name
to existing KIM API lib (see example below)
to existing KIM API lib (see example below).
If kim-name = everything, then rebuild KIM API library with
all available OpenKIM Models (this implies -b).
-vv = be more verbose about what is happening while the script runs
Examples:
Examples:
make lib-kim args=
"
-b
. none
"
# install KIM API lib with only example models
make lib-kim args=
"
-b
"
# install KIM API lib with only example models
make lib-kim args=
"
-b
.
Glue_Ercolessi_Adams_Al__MO_324507536345_001
"
#
d
itto plus one model
make lib-kim args=
"
-b
-a
Glue_Ercolessi_Adams_Al__MO_324507536345_001
"
#
D
itto plus one model
make lib-kim args=
"
-b
. OpenKIM
"
# install KIM API lib with all models
make lib-kim args=
"
-b
-a everything
"
# install KIM API lib with all models
make lib-kim args=
"
-a EAM_Dynamo_Ackland_W__MO_141627196590_002
"
# add one model or model driver
make lib-kim args=
"
-a EAM_Dynamo_Ackland_W__MO_141627196590_002
"
# add one model or model driver
See the list of KIM model drivers here:
See the list of KIM model drivers here:
...
@@ -57,7 +54,9 @@ thisdir = os.environ['PWD']
...
@@ -57,7 +54,9 @@ thisdir = os.environ['PWD']
version
=
"
kim-api-v1.8.2
"
version
=
"
kim-api-v1.8.2
"
buildflag
=
False
buildflag
=
False
everythingflag
=
False
addflag
=
False
addflag
=
False
verboseflag
=
False
iarg
=
0
iarg
=
0
while
iarg
<
len
(
args
):
while
iarg
<
len
(
args
):
...
@@ -67,15 +66,19 @@ while iarg < len(args):
...
@@ -67,15 +66,19 @@ while iarg < len(args):
iarg
+=
2
iarg
+=
2
elif
args
[
iarg
]
==
"
-b
"
:
elif
args
[
iarg
]
==
"
-b
"
:
buildflag
=
True
buildflag
=
True
if
iarg
+
3
>
len
(
args
):
error
()
iarg
+=
1
dir
=
args
[
iarg
+
1
]
modelname
=
args
[
iarg
+
2
]
iarg
+=
3
elif
args
[
iarg
]
==
"
-a
"
:
elif
args
[
iarg
]
==
"
-a
"
:
addflag
=
True
addflag
=
True
if
iarg
+
2
>
len
(
args
):
error
()
if
iarg
+
2
>
len
(
args
):
error
()
addmodelname
=
args
[
iarg
+
1
]
addmodelname
=
args
[
iarg
+
1
]
if
addmodelname
==
"
everything
"
:
buildflag
=
True
everythingflag
=
True
addflag
=
False
iarg
+=
2
iarg
+=
2
elif
args
[
iarg
]
==
"
-vv
"
:
verboseflag
=
True
iarg
+=
1
else
:
error
()
else
:
error
()
thisdir
=
os
.
path
.
abspath
(
thisdir
)
thisdir
=
os
.
path
.
abspath
(
thisdir
)
...
@@ -88,14 +91,14 @@ if buildflag:
...
@@ -88,14 +91,14 @@ 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
(
this
dir
),
"
installed-
"
+
version
)
# check to see if an installed kim-api already exists and wipe it out.
# 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.
\n
Removing it for re-install
"
%
dir
)
print
(
"
kim-api is already installed at %s.
\n
Removing it for re-install
"
%
dir
)
cmd
=
"
rm -rf %s
"
%
dir
cmd
=
"
rm -rf %s
"
%
dir
subprocess
.
check_output
(
cmd
,
shell
=
True
)
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
# configure LAMMPS to use kim-api to be installed
# configure LAMMPS to use kim-api to be installed
...
@@ -116,44 +119,48 @@ if buildflag:
...
@@ -116,44 +119,48 @@ if buildflag:
geturl
(
url
,
"
%s/%s.tgz
"
%
(
thisdir
,
version
))
geturl
(
url
,
"
%s/%s.tgz
"
%
(
thisdir
,
version
))
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
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
# 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
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
# build kim-api
# build kim-api
print
(
"
Configuring model : %s
"
%
modelname
)
print
(
"
Configuring example Models
"
)
if
modelname
==
"
none
"
:
cmd
=
"
cd %s/%s; make add-examples
"
%
(
thisdir
,
version
)
cmd
=
"
cd %s/%s; make add-examples
"
%
(
thisdir
,
version
)
txt
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
else
:
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
if
modelname
==
"
OpenKIM
"
:
print
(
"
configuring all OpenKIM models, this will take a while ...
"
)
if
everythingflag
:
cmd
=
"
cd %s/%s; make add-examples; make add-%s
"
%
\
print
(
"
Configuring all OpenKIM models, this will take a while ...
"
)
(
thisdir
,
version
,
modelname
)
cmd
=
"
cd %s/%s; make add-OpenKIM
"
%
(
thisdir
,
version
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
txt
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
print
(
"
Building kim-api ...
"
)
print
(
"
Building kim-api ...
"
)
cmd
=
"
cd %s/%s; make
"
%
(
thisdir
,
version
)
cmd
=
"
cd %s/%s; make
"
%
(
thisdir
,
version
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
txt
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
# 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
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
txt
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
cmd
=
"
cd %s/%s; make install-set-default-to-v1
"
%
(
thisdir
,
version
)
cmd
=
"
cd %s/%s; make install-set-default-to-v1
"
%
(
thisdir
,
version
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
txt
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
# 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
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
# add a single model (and possibly its driver) to existing KIM installation
# add a single model (and possibly its driver) to existing KIM installation
...
@@ -166,19 +173,18 @@ if addflag:
...
@@ -166,19 +173,18 @@ 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
.
check_output
(
cmd
,
shell
=
True
)[
1
]
dir
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)[
1
]
# download single model
# download single model
# try first via urllib
# try first via urllib
# if fails (probably due to no SSL support), use wget
print
(
"
Downloading
item
tarball
...
"
)
print
(
"
Downloading tarball
for %s...
"
%
addmodelname
)
url
=
"
https://openkim.org/download/%s.tgz
"
%
addmodelname
url
=
"
https://openkim.org/download/%s.tgz
"
%
addmodelname
geturl
(
url
,
"
%s/%s.tgz
"
%
(
thisdir
,
addmodelname
))
geturl
(
url
,
"
%s/%s.tgz
"
%
(
thisdir
,
addmodelname
))
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
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
print
(
"
Building item ...
"
)
print
(
"
Building item ...
"
)
cmd
=
"
cd %s/%s; make; make install
"
%
(
thisdir
,
addmodelname
)
cmd
=
"
cd %s/%s; make; make install
"
%
(
thisdir
,
addmodelname
)
...
@@ -187,19 +193,19 @@ if addflag:
...
@@ -187,19 +193,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
.
decode
(
"
UTF-8
"
)
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
(
)
txt
=
txt
.
decode
(
"
UTF-8
"
)
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
.
decode
().
strip
()
adddrivername
=
txt
.
decode
(
"
UTF-8
"
).
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
)
...
@@ -207,6 +213,8 @@ if addflag:
...
@@ -207,6 +213,8 @@ if addflag:
print
(
e
.
output
)
print
(
e
.
output
)
sys
.
exit
()
sys
.
exit
()
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
))
# now install the model that needed the driver
# now install the model that needed the driver
print
(
"
Now installing model : %s
"
%
addmodelname
)
print
(
"
Now installing model : %s
"
%
addmodelname
)
...
@@ -216,7 +224,7 @@ if addflag:
...
@@ -216,7 +224,7 @@ if addflag:
except
subprocess
.
CalledProcessError
as
e
:
except
subprocess
.
CalledProcessError
as
e
:
print
(
e
.
output
)
print
(
e
.
output
)
sys
.
exit
()
sys
.
exit
()
print
(
txt
.
decode
())
print
(
txt
.
decode
(
"
UTF-8
"
))
sys
.
exit
()
sys
.
exit
()
else
:
else
:
print
(
firstRunOutput
)
print
(
firstRunOutput
)
...
@@ -226,7 +234,7 @@ if addflag:
...
@@ -226,7 +234,7 @@ if addflag:
# success the first time
# success the first time
print
(
txt
)
if
verboseflag
:
print
(
txt
.
decode
(
"
UTF-8
"
)
)
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
)
subprocess
.
check_output
(
cmd
,
shell
=
True
)
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment