-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAutoWIG.py
More file actions
103 lines (88 loc) · 3.54 KB
/
Copy pathAutoWIG.py
File metadata and controls
103 lines (88 loc) · 3.54 KB
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
import os
import autowig
import pickle
import subprocess
import multiprocessing
import shutil
jobs = str(max(multiprocessing.cpu_count()-1, 1))
asgs = dict()
try:
for filepath in os.listdir(os.path.join(autowig.__path__[0], '..', 'scons_tools', 'site_autowig', 'ASG')):
with open(os.path.join(autowig.__path__[0], '..', 'scons_tools', 'site_autowig', 'ASG', filepath), 'rb') as filehandler:
asgs[filepath] = pickle.load(filehandler)
except:
pass
subprocess.call(['scons', 'autowig', '-j' + jobs, '-c'])
subprocess.call(['scons', '-j' + jobs, '-c'])
variant_dir = 'build/src'
src_dir = 'src'
asgs = [asg for filepath, asg in asgs.items() if not os.path.exists(filepath)]
for asg in asgs:
for bpm in asg.boost_python_modules():
if bpm.globalname.startswith(os.path.abspath('.')):
bpm.remove()
bpd = bpm.decorator
if bpd:
bpd.remove()
bpm.header.remove()
for bpe in bpm.exports:
bpe.remove()
for asg in asgs:
for pbm in asg.pybind11_modules():
if pbm.globalname.startswith(os.path.abspath('.')):
pbm.remove()
pbd = pbm.decorator
if pbd:
pbd.remove()
pbm.header.remove()
for pbe in pbm.exports:
pbe.remove()
subprocess.call(['scons', '-j' + jobs, '-k', '--diagnostics-color=never'])
s = subprocess.Popen(['scons', 'autowig', '-j' + jobs, '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
out, err = s.communicate()
with open(os.path.join(autowig.__path__[0], '..', 'scons_tools', 'site_autowig', 'ASG', 'statiskit_linalg.pkl'), 'rb') as filehandler:
asg = pickle.load(filehandler)
os.environ['AutoWIG'] = 'true'
# autowig.feedback.plugin = 'edit'
# changed = True
# s = subprocess.Popen(['scons', '-j' + jobs, '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
# out, curr = s.communicate()
# s = subprocess.Popen(['scons', '-j1', '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
# prev = ''
# out, curr = s.communicate()
# curr = curr.decode()
# with open('controller.py', 'w') as filehandler:
# while changed and not prev == curr:
# prev = curr
# changed = False
# code = autowig.feedback(curr, '.', asg, variant_dir=variant_dir,
# src_dir=src_dir)
# if code.strip():
# changed = True
# filehandler.write(code)
# print(code)
# input("Press Enter to continue...")
# exec(code, locals())
# for bpm in asg.boost_python_modules():
# if bpm.globalname.startswith(os.path.abspath('.')):
# bpm.write()
# s = subprocess.Popen(['scons', '-j' + jobs, '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
# out, curr = s.communicate()
# s = subprocess.Popen(['scons', '-j1', '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
# out, curr = s.communicate()
# curr = curr.decode()
autowig.feedback.plugin = 'comment'
prev = None
curr = ''
while not prev == curr:
if not prev == curr:
prev = curr
autowig.feedback(curr, '.', asg, variant_dir=variant_dir,
src_dir=src_dir)
s = subprocess.Popen(['scons', '-j1', '-k', '--diagnostics-color=never'], stderr=subprocess.PIPE)
out, curr = s.communicate()
curr = curr.decode()
else:
print("done")
os.environ['AutoWIG'] = 'false'
subprocess.call(['scons', '-j' + jobs])