-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpostBuild
38 lines (32 loc) · 1.11 KB
/
postBuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# postBuild for AFLOW SCHOOL
# download and setup aflow binary
import subprocess
import sys
from pathlib import Path
from urllib import request
print("Preparing AFLOW SCHOOL environment")
def run(*args, **kwargs):
# Run a command, echoing the args; fails hard if something goes wrong
print("\t", " ".join(args))
return_code = subprocess.call(args, **kwargs)
if return_code != 0:
print("\nERROR", return_code, " ".join(args))
sys.exit(return_code)
# folder setup
print(" Creating Folders")
bin_folder = Path("~/.local/bin")
bin_folder = bin_folder.expanduser().resolve()
bin_folder.mkdir(parents=True, exist_ok=True)
# binary setup
print(" Installing prebuild aflow")
aflow_prebuild_url = "http://aflowlib.duke.edu/AFLOW_SCHOOL/AFLOW_BIN/aflow_3.2.13_ults18"
aflow_path = bin_folder / "aflow"
aflow_data_path = bin_folder / "aflow_data"
request.urlretrieve(aflow_prebuild_url, filename=aflow_path.absolute())
aflow_data_path.touch()
aflow_path.chmod(0o777)
aflow_data_path.chmod(0o777)
# test if install worked
run('aflow', '--version', cwd='/tmp')
print("Preparations done!")