-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.py
executable file
·170 lines (150 loc) · 5.64 KB
/
configure.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
#!/usr/bin/env python
import os
import sys
from glob import glob
import json
from distutils.file_util import copy_file, move_file
from distutils.dir_util import mkpath, remove_tree
from copy import deepcopy
from Cython.Compiler.Version import version as CYTHON_VERSION
INFO = {'version': '0.6-dev',}
def main():
"Run functions specified on the command line"
if len(sys.argv) <= 1:
raise SystemExit("no command(s) specified")
cmds = sys.argv[1:]
if '-h' in cmds or '--help' in cmds:
raise SystemExit("usage: " + sys.argv[0] + " <func-name> [<func-name>]")
glbs = globals()
for cmd in cmds:
if cmd not in glbs:
raise SystemExit(cmd + " not found")
for cmd in cmds:
if callable(glbs[cmd]):
glbs[cmd]()
else:
raise SystemExit(cmd + " not callable")
def metadata(path="bright/metadata.json"):
"""Build a metadata file."""
md = {}
md.update(INFO)
# FIXME: Add the contents of CMakeCache.txt to the metadata dictionary
# write the metadata file
with open(path, 'w') as f:
json.dump(md, f, indent=2)
return md
def final_message(success=True):
if success:
return
metadata = None
mdpath = os.path.join('bright', 'metadata.json')
if os.path.exists(mdpath):
with open(mdpath) as f:
metadata = json.load(f)
if metadata is not None:
msg = "\n\nCURRENT METADATA:\n"
for k, v in sorted(metadata.items()):
msg += " {0} = {1}\n".format(k, repr(v))
print msg[:-1]
if os.name != 'nt':
return
try:
import tables as tb
h5ver = tb.getHDF5Version()
except ImportError:
h5ver = '1.8.5-patch1'
msg = ("\n\nUSAGE: "
"python setup.py <distutils-args> [-- <cmake-arg>] [-- <make-args>]\n"
"CMake and make command line arguments are optional, but must be preceeded "
"by '--'.\n"
"\n\nIf compilation is failing with HDF5 issues please try the "
"following steps:\n\n"
" 1. Install EPD [1].\n"
" 2. Download the HDF5 Windows binarys from [2].\n"
" 3. Unzip them to the C-drive (C:\\hdf5-{h5ver}).\n"
" 4. Re-run setup with the '--hdf5' option:\n\n"
" python setup.py install --user --hdf5=C:\\hdf5-{h5ver}\n\n"
"Should this still fail, please report your problem to [email protected]\n\n"
"[1] http://www.enthought.com/products/epd.php\n"
"[2] http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-{h5ver}/bin/windows/\n"
).format(h5ver=h5ver)
print msg
def cython_version():
pxi = ("# Cython compile-time version information\n"
"DEF CYTHON_VERSION_MAJOR = {major}\n"
"DEF CYTHON_VERSION_MINOR = {minor}\n"
"DEF CYTHON_VERSION_MICRO = {micro}")
cyver = CYTHON_VERSION.split('-')[0].split('.')
while len(cyver) < 3:
cyver = cyver + [0]
cyver = dict([(k, int(cv)) for k, cv in zip(['major', 'minor', 'micro'], cyver)])
pxi = pxi.format(**cyver)
basedir = os.path.split(__file__)[0]
incldir = os.path.join(basedir, 'bright', 'include')
if not os.path.exists(incldir):
os.mkdir(incldir)
with open(os.path.join(incldir, 'cython_version.pxi'), 'w') as f:
f.write(pxi)
def setup():
from distutils import core
scripts = [os.path.join('scripts', f) for f in os.listdir('scripts')]
scripts = [s for s in scripts if (os.name == 'nt' and s.endswith('.bat')) or
(os.name != 'nt' and not s.endswith('.bat'))]
packages = ['bright',
'bright.gui',
'bright.gui.models',
'bright.apigen',
'bright.apigen.clang',
'bright.apigen.clang.v3_1',
'bright.apigen.clang.v3_2',
'bright.gui.models.class_models',
'bright.gui.views',
'bright.gui.d3',
'bright.gui.views.component_views',
'bright.gui.views.custom_graph_canvas',
'bright.gui.views.component_views.views',
'bright.data',
'bright.xsgen',
'bright.xsgen.run',
'bright.xsgen.ui',
]
pack_dir = {
'bright': 'bright',
'bright.gui': 'bright/gui',
'bright.data': 'data',
'bright.apigen': 'bright/apigen',
}
extpttn = ['*.dll', '*.so', '*.dylib', '*.pyd', '*.pyo']
pack_data = {
'lib': extpttn,
'bright': ['*.pxd', 'include/*.h', 'include/*/*.h', 'include/*/*/*.h',
'include/*/*/*/*.h', 'include/bright/*.pxd',
'include/bright/*/*.pxd', 'include/bright/*/*/*.pxd',
'include/bright/*/*/*/*.pxd', '*.json',] + extpttn,
'bright.gui': ['*.pyw'],
'bright.data': ['*.h5',],
'bright.apigen': ['*.h', '*.json'],
}
libbrights = set()
for ext in extpttn:
libbrights |= set(glob('cpp/' + ext))
data_files = [
('lib', libbrights),
('include/bright', glob('../cpp/*.h')),
]
setup_kwargs = {
"name": "bright",
"version": INFO['version'],
"description": 'Bright Nuclear Fuel Cycle Components',
"author": 'Anthony Scopatz',
"author_email": '[email protected]',
"url": 'http://bright-dev.github.com/bright/',
"packages": packages,
"package_dir": pack_dir,
"package_data": pack_data,
"data_files": data_files,
"scripts": scripts,
}
rtn = core.setup(**setup_kwargs)
if __name__ == "__main__":
main()