forked from Danielaleite/Nextrout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·172 lines (145 loc) · 5.42 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!usr/bin/env python3
import os
import os.path
import contextlib
@contextlib.contextmanager
def change_temporarily_into(dir):
"""doing cd into dir and go back to the original directory afterwards."""
current_dir = os.getcwd()
try:
os.chdir(dir)
yield
except Exception as e:
if isinstance(e, FileNotFoundError):
print("I am in {}".format(os.getcwd()))
print("You are trying to cd into {}".format(dir))
print("Available directories:{}".format(os.listdir(os.getcwd())))
raise e
finally:
os.chdir(current_dir)
def execute(commands_in_dir):
"""Execute a list of commands in a directory.
Keys are directories, values are lists of commands.
"""
def execute_in_dir(dir, commands):
with change_temporarily_into(dir):
for cmd in commands:
os.system(cmd)
for dir, commands in list(commands_in_dir.items()):
execute_in_dir(dir, commands)
# Download dependencies for the first step and backend for filtering
download_commands = {"./otp_utilities": ["./init_otp_muffe.sh"]}
execute(download_commands)
# Build commands
build_commands = {
"otp_utilities/geometry": ["./make_all.sh",],
"otp_utilities/globals": ["./make all.sh",],
"otp_utilities/linear_algebra/code": ["make clobber", "make dirs", "make",],
"otp_utilities/linear_algebra/Mxv": ["make clobber", "make dirs", "make",],
"otp_utilities/linear_algebra/test": ["make clobber", "make dirs", "make",],
"otp_utilities/muffe_p1p0/code": ["make clobber", "make dirs", "make",],
"otp_utilities/muffe_p1p0/preprocess/2d_assembly/subgrid_preprocess/code": [
"make clobber",
"make dirs",
"make",
],
"otp_utilities/muffe_p1p0/python_interface": ["make clobber", "make dirs", "make",],
"otp_utilities/muffe_sparse_optimization/code": [
"make clobber",
"make dirs",
"make",
],
"otp_utilities/p1galerkin/code": ["make clobber", "make dirs", "make",],
"otp_utilities/p1galerkin/assembly_stiff": ["make clobber", "make dirs", "make",],
"otp_utilities/p1galerkin/dirac2rhs": ["make clobber", "make dirs", "make",],
"otp_utilities/p1galerkin/eval_divergence_constrain": [
"make clobber",
"make dirs",
"make",
],
"otp_utilities/p1galerkin/eval_gradient": ["make clobber", "make dirs", "make",],
"otp_utilities/p1galerkin/makerhs": ["make clobber", "make dirs", "make",],
"otp_utilities/p1galerkin/Laplace_Convergence": [
"make clobber",
"make dirs",
"make",
],
"otp_utilities/spectral/src": ["make clobber", "make dirs", "make",],
"otp_utilities/vtk": ["make clobber", "make dirs", "make",],
}
execute(build_commands)
build_directories = {
"otp_utilities/muffe_p1p0": ["./setup.sh ../../python_scripts"],
"otp_utilities/muffe_sparse_optimization/": ["./setup.sh simplifications"],
"otp_utilities/par_files": [
"cp utilities.py ../muffe_sparse_optimization/python_script",
],
"python_scripts": [
"cp utilities.py ../otp_utilities/muffe_sparse_optimization/simplifications/python_script",
],
}
"""
"mv continuous2graph.py ../python_scripts",
"mv debugger.py ../python_scripts",
"mv discrete2graph.py ../python_scripts",
"mv filtering.py ../python_scripts",
"mv get_graph.py ../python_scripts",
"mv Getting_sources_and_sinks.py ../python_scripts",
"mv graph2plotly.py ../python_scripts",
"mv main.py ../python_scripts",
"mv pre_extraction.py ../python_scripts",
"mv quality_measure.py ../python_scripts",
"mv source_sink_generator.py ../python_scripts",
"mv steiner_simplification.py ../python_scripts",
"mv transport_networks.py ../python_scripts",
"mv utilities.py ../python_scripts",
"mv utils.py ../python_scripts",
"mv terminal_computation.py ../python_scripts",
"mv utilities.py ../python_scripts/python_script",
"mv graph_cell_folder ../python_scripts/",
"mv par_files ../python_scripts/simplifications/",
"mv images ../python_scripts",
"mv PVM_data ../python_scripts",
],
"""
execute(build_directories)
make_command = {
"otp_utilities/muffe_p1p0/code": ["make",],
"otp_utilities/globals/axpy_timedata": ["make",],
"otp_utilities/geometry/interpolate_timedata/": ["make",],
}
execute(make_command)
move_folders = {
"otp_utilities/par_files": [
"cp dmk_folder_structure.py ../../python_scripts/python_script"
],
"otp_utilities/par_files": ["cp utilities.py ../../python_scripts/python_script"],
}
execute(move_folders)
move_folders2 = {
"otp_utilities/": [" cp -r par_files ./muffe_sparse_optimization/simplifications/"],
}
execute(move_folders2)
move_folders3 = {
"otp_utilities/par_files": [
" cp muffa.fnames ../muffe_sparse_optimization/simplifications/"
],
}
execute(move_folders3)
move_folders4 = {
"otp_utilities/par_files": [
" cp dmk_folder_structure.py ../muffe_sparse_optimization/simplifications/python_script"
],
}
execute(move_folders4)
move_folders5 = {
"otp_utilities/par_files": [
"cp utilities.py ../muffe_sparse_optimization/simplifications/python_script"
],
}
execute(move_folders5)
make_dir = {
".": [" mkdir results", "mkdir results/discrete", "mkdir results/continuous"]
}
execute(make_dir)
print("Setup is finished!")