-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup.py
117 lines (92 loc) · 3.32 KB
/
setup.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import argparse
import subprocess
import os
import shutil
import sys
current_directory = os.getcwd()
def runTerminal(cmd):
subprocess.call(cmd, shell=True)
def remove():
runTerminal("rm -rf lammps")
runTerminal("make clean")
def cloneLammps(head):
runTerminal("git clone https://github.com/ovilab/lammps.git")
if not head:
os.chdir("./lammps")
runTerminal("git checkout master")
os.chdir(current_directory)
def updateLammps():
os.chdir("./lammps")
runTerminal("git pull")
os.chdir(current_directory)
def cleanPackages():
os.chdir("./lammps/src")
runTerminal("make no-all")
os.chdir(current_directory)
def activatePackage(package):
os.chdir("./lammps/src")
runTerminal("make yes-"+package)
os.chdir(current_directory)
def standardPackages():
cleanPackages()
activatePackage("mc")
activatePackage("molecule")
activatePackage("manybody")
def compile():
makeStyles()
runTerminal("patch -f %s < %s" % (os.path.join("lammps","src","modify.cpp"), os.path.join("patches", "modify.cpp.patch")))
shutil.copy(os.path.join("cpp", "lammpscontroller.cpp"), os.path.join("lammps","src"))
shutil.copy(os.path.join("cpp", "fix_atomify.cpp"), os.path.join("lammps","src"))
shutil.copy(os.path.join("cpp", "fix_atomify.h"), os.path.join("lammps","src"))
shutil.copy(os.path.join("lammps", "src", "STUBS", "mpi.c"), os.path.join("lammps","src", "mpi.cpp"))
runTerminal("make -j 4 wasm")
def makeStyles():
os.chdir("./lammps/src")
runTerminal("/bin/bash Make.sh style")
os.chdir(current_directory)
helpstr = "Atomify LAMMPS Online compiler v 0.99.\n" + \
"LAMMPS Github repository: https://github.com/lammps/lammps\n" + \
"Example commands:\n" + \
" python setup.py install\n" + \
" python setup.py install --packages none\n" + \
" python setup.py install --head --packages standard\n" + \
"\n" + \
"or run 'python setup.py --help' for more information. \n"
lammpsdirExists = os.path.isdir("./lammps")
parser = argparse.ArgumentParser(description=helpstr, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("command", help="command can be one of the following: 'install', 'clone', 'update', 'remove', 'cleanpackages'")
parser.add_argument('-p','--packages', nargs='*', help='LAMMPS packages ("-p none" for no packages, or provide a list of packages.)', required=False)
parser.add_argument('--head', help='clone newest version at head commit. WARNING, this might not compile.', required=False, action='store_true')
if len(sys.argv) == 1:
print helpstr
args = parser.parse_args()
command = args.command
print "Packages: ", args.packages
if not command in ["install", "clone", "update", "remove", "cleanpackages", "compile"]:
print "Error, '"+command+"' is not a valid command. Must be one of 'install', 'update', 'remove'"
exit()
if command == "remove":
remove()
exit()
if command == "cleanpackages":
cleanPackages()
exit()
if command == "clone":
cloneLammps()
if command == "update":
if not lammpsdirExists: cloneLammps(True)
updateLammps()
if command == "compile":
if not lammpsdirExists: cloneLammps(True)
compile()
if command == "install":
if not lammpsdirExists: cloneLammps(args.head)
if args.head == False:
updateLammps()
if not args.packages is None:
if args.packages[0] == "none": cleanPackages()
else:
for package in args.packages:
activatePackage(package)
else: standardPackages()
compile()