forked from praxes/praxes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
252 lines (202 loc) · 6.62 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
from __future__ import print_function
from distutils.core import setup
from distutils.cmd import Command
from distutils.command.sdist import sdist as _sdist
from distutils.command.build import build as _build
from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
from distutils.extension import Extension
from glob import glob
import multiprocessing
import os
import subprocess
import sys
from Cython.Distutils import build_ext
import numpy
def convert_data(args):
if not os.path.exists(args[-1]):
try:
subprocess.check_call(args)
except subprocess.CalledProcessError:
print("""\
Warning: Could not configure %s.
See README to configure repository.
""" % (os.path.split(args[-1]))[0])
class data(Command):
description = "Process databases into the structures used by praxes"
user_options = []
boolean_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def process_elam(self):
return (
sys.executable,
'praxes/physref/elam/create_db',
'praxes/physref/elam/elam.dat',
'praxes/physref/elam/elam.db'
)
def process_waasmaier(self):
return (
sys.executable,
'praxes/physref/waasmaier/create_db',
'praxes/physref/waasmaier/waasmaier_kirfel.dat',
'praxes/physref/waasmaier/waasmaier_kirfel.db'
)
def run(self):
to_process = [
self.process_elam(),
self.process_waasmaier(),
]
if sys.platform.startswith('win'):
#doing this in parallel on windows will crash your computer
[convert_data(args) for args in to_process]
else:
pool = multiprocessing.Pool()
pool.map(convert_data, to_process)
class test(Command):
"""Run the test suite."""
description = "Run the test suite"
user_options = [('verbosity', 'v', 'set test report verbosity')]
def initialize_options(self):
self.verbosity = 0
def finalize_options(self):
try:
self.verbosity = int(self.verbosity)
except ValueError:
raise ValueError('Verbosity must be an integer.')
def run(self):
import sys
if sys.version.startswith('3.1'):
import unittest2 as unittest
else:
import unittest
suite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=self.verbosity+1).run(suite)
def convert_ui(args, **kwargs):
subprocess.call(args, **kwargs)
class ui_cvt(Command):
description = "Convert Qt user interface files to PyQt .py files"
user_options = []
boolean_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
to_process = []
for root, dirs, files in os.walk('praxes'):
for f in files:
if f.endswith('.ui'):
source = os.path.join(root, f)
dest = os.path.splitext(source)[0]+'.py'
exe = 'pyuic4'
elif f.endswith('.qrc'):
source = os.path.join(root, f)
dest = os.path.splitext(source)[0]+'_rc.py'
exe = 'pyrcc4'
else:
continue
if not os.path.exists(dest):
to_process.append([exe, '-o', dest, source])
if sys.platform.startswith('win'):
# doing this in parallel on windows will crash your computer
[convert_ui(args, shell=True) for args in to_process]
else:
pool = multiprocessing.Pool()
pool.map(convert_ui, to_process)
except EnvironmentError:
print("""\
Warning: PyQt4 development utilities (pyuic4 and pyrcc4) not found
Unable to install praxes' graphical user interface
""")
class sdist(_sdist):
def run(self):
self.run_command('data')
self.run_command('ui_cvt')
_sdist.run(self)
class build(_build):
def run(self):
self.run_command('data')
self.run_command('ui_cvt')
_build.run(self)
class bdist_wininst(_bdist_wininst):
def run(self):
self.run_command('data')
self.run_command('ui_cvt')
_bdist_wininst.run(self)
packages = []
for dirpath, dirnames, filenames in os.walk('praxes'):
if '__init__.py' in filenames:
packages.append('.'.join(dirpath.split(os.sep)))
else:
del(dirnames[:])
with open('praxes/version.py') as f:
for line in f:
if line[:11] == '__version__':
exec(line)
break
ext_modules = [
Extension('praxes.io.spec.file', ['praxes/io/spec/file.pyx']),
Extension(
'praxes.io.spec.proxies',
['praxes/io/spec/proxies.pyx'],
include_dirs=[numpy.get_include()]
),
Extension('praxes.io.spec.mapping', ['praxes/io/spec/mapping.pyx']),
Extension('praxes.io.spec.scan', ['praxes/io/spec/scan.pyx']),
Extension('praxes.rlock', ['praxes/rlock.pyx']),
Extension(
'_tifffile',
['praxes/io/tifffile.c'],
include_dirs=[numpy.get_include()]
)
]
package_data = {
'praxes': [
'fluorescence/ui/icons/*.svg',
'instrumentation/spec/macros/*.mac',
'instrumentation/spec/ui/icons/*.svg',
],
}
package_data['praxes'].extend(
[i.split('/',1)[-1] for i in glob('praxes/physref/*/*.db')]
)
scripts = [
'scripts/combi',
]
if sys.platform.startswith('win'):
# scripts calling multiprocessing must be importable
import shutil
shutil.copy('scripts/sxfm', 'scripts/sxfm.py')
scripts.append('scripts/sxfm.py')
else:
scripts.append('scripts/sxfm')
if ('bdist_wininst' in sys.argv) or ('bdist_msi' in sys.argv):
scripts.append('scripts/praxes_win_post_install.py')
setup(
author = 'Darren Dale',
author_email = '[email protected]',
cmdclass = {
'bdist_wininst': bdist_wininst,
'build': build,
'build_ext': build_ext,
'data': data,
'sdist': sdist,
'test': test,
'ui_cvt': ui_cvt,
},
description = 'Praxes framework for scientific analysis',
ext_modules = ext_modules,
name = 'praxes',
package_data = package_data,
packages = packages,
requires = (
'python (>=2.7)',
'cython (>=0.13)',
'numpy (>=1.5.1)',
),
scripts = scripts,
version = __version__,
)