forked from gwastro/pycbc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
470 lines (426 loc) · 18.2 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#!/usr/bin/python
# Copyright (C) 2012 Alex Nitz, Andrew Miller, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
setup.py file for PyCBC package
"""
import os, fnmatch, sys, subprocess, shutil
from trace import fullmodname
try:
from setuptools.command.install import install as _install
from setuptools.command.install_egg_info import install_egg_info as egg_info
USE_SETUPTOOLS = True
except:
from distutils.command.install import install as _install
USE_SETUPTOOLS = False
from distutils.errors import DistutilsError
from distutils.core import setup, Command, Extension
from distutils.command.clean import clean as _clean
from distutils.file_util import write_file
from distutils.version import LooseVersion
try:
import numpy.version
if LooseVersion(numpy.version.version) < LooseVersion("1.6.4"):
print (" Numpy >= 1.6.4 is required for pycbc dependencies. \n"
" We found version %s already installed. Please update \n"
" to a more recent version and then retry PyCBC \n"
" installation. \n"
" \n"
" Using pip: [pip install 'numpy>=1.6.4' --upgrade --user] \n"
"" % numpy.version.version)
# exit(1)
except ImportError:
pass
requires = ['lal.lal', 'lalsimulation.lalsimulation', 'glue', 'pylal']
setup_requires = []
install_requires = setup_requires + ['Mako>=1.0.1',
'argparse>=1.3.0',
'decorator>=3.4.2',
'scipy>=0.13.0',
'unittest2',
'matplotlib>=1.3.1',
'numpy>=1.6.4',
'pillow',
'h5py>=2.5',
'jinja2',
'mpld3>=0.3git',
'pyRXP>=2.1.0',
'pycbc-pylal>=0.9.5',
'pycbc-glue>=0.9.6',
]
links = ['https://github.com/ligo-cbc/mpld3/tarball/master#egg=mpld3-0.3git']
#FIXME Remove me when we bump to h5py > 2.5
try:
import h5py
except ImportError:
setup_requires.append('cython')
else:
import h5py.version
if h5py.version.version < '2.5':
setup_requires.append('cython')
def find_package_data(dirname):
def find_paths(dirname):
items = []
for fname in os.listdir(dirname):
path = os.path.join(dirname, fname)
if os.path.isdir(path):
items += find_paths(path)
elif not path.endswith(".py") and not path.endswith(".pyc"):
items.append(path)
return items
items = find_paths(dirname)
return [os.path.relpath(path, dirname) for path in items]
# Add swig-generated files to the list of things to clean, so they
# get regenerated each time.
class clean(_clean):
def finalize_options (self):
_clean.finalize_options(self)
self.clean_files = []
self.clean_folders = ['docs/_build']
def run(self):
_clean.run(self)
for f in self.clean_files:
try:
os.unlink(f)
print 'removed {0}'.format(f)
except:
pass
for fol in self.clean_folders:
shutil.rmtree(fol, ignore_errors=True)
print 'removed {0}'.format(fol)
class install(_install):
def run(self):
etcdirectory = os.path.join(self.install_data, 'etc')
if not os.path.exists(etcdirectory):
os.makedirs(etcdirectory)
filename = os.path.join(etcdirectory, 'pycbc-user-env.sh')
self.execute(write_file,
(filename, [self.extra_dirs]),
"creating %s" % filename)
env_file = open(filename, 'w')
print >> env_file, "# Source this file to access PyCBC"
print >> env_file, "PATH=" + self.install_scripts + ":$PATH"
print >> env_file, "PYTHONPATH=" + self.install_libbase + ":$PYTHONPATH"
print >> env_file, "export PYTHONPATH"
print >> env_file, "export PATH"
env_file.close()
_install.run(self)
def do_setup(*args):
return True
_install._called_from_setup=do_setup
test_results = []
# Run all of the testing scripts
class TestBase(Command):
user_options = []
test_modules = []
def initialize_options(self):
self.scheme = None
self.build_dir = None
def finalize_options(self):
#Populate the needed variables
self.set_undefined_options('build',('build_lib', 'build_dir'))
def find_test_modules(self,pattern):
# Find all the unittests that match a given string pattern
modules= []
for path, dirs, files in os.walk("test"):
for filename in fnmatch.filter(files, pattern):
#add the test directories to the path
sys.path.append(os.path.join(path))
#save the module name for importing
modules.append(fullmodname(filename))
return modules
def run(self):
self.run_command('build')
# Get the list of cpu test modules
self.test_modules = self.find_test_modules("test*.py")
# Run from the build directory
if 'PYTHONPATH' in os.environ:
os.environ['PYTHONPATH'] = self.build_dir + ":" + os.environ['PYTHONPATH']
else:
os.environ['PYTHONPATH'] = self.build_dir
test_results.append("\n" + (self.scheme + " tests ").rjust(30))
for test in self.test_modules:
test_command = 'python ' + 'test/' + test + '.py -s ' + self.scheme
a = subprocess.call(test_command,env=os.environ,shell=True)
if a != 0:
result_str = str(test).ljust(30) + ": Fail : " + str(a)
else:
result_str = str(test).ljust(30) + ": Pass"
test_results.append(result_str)
for test in test_results:
print test
class test(Command):
def has_cuda(self):
import pycbc
return pycbc.HAVE_CUDA
sub_commands = [('test_cpu',None),('test_cuda',has_cuda)]
user_options = []
description = "run the available tests for all compute schemes (cpu, cuda)"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
for cmd_name in self.get_sub_commands():
self.run_command(cmd_name)
class test_cpu(TestBase):
description = "run all CPU tests"
def initialize_options(self):
TestBase.initialize_options(self)
self.scheme = 'cpu'
class test_cuda(TestBase):
description = "run CUDA tests"
def initialize_options(self):
TestBase.initialize_options(self)
self.scheme = 'cuda'
# write versioning info
def get_version_info():
"""Get VCS info and write version info to version.py
"""
from pycbc import _version_helper
# If this is a pycbc git repo always populate versoin information using GIT
try:
vcs_info = _version_helper.generate_git_version_info()
with open('pycbc/version.py', 'w') as f:
f.write("# Generated by setup.py for PyCBC on %s.\n\n"
% vcs_info.build_date)
# print general info
f.write('version = \'%s\'\n' % vcs_info.version)
f.write('date = \'%s\'\n' % vcs_info.date)
f.write('release = %s\n' % vcs_info.release)
# print git info
f.write('\ngit_hash = \'%s\'\n' % vcs_info.hash)
f.write('git_branch = \'%s\'\n' % vcs_info.branch)
f.write('git_tag = \'%s\'\n' % vcs_info.tag)
f.write('git_author = \'%s\'\n' % vcs_info.author)
f.write('git_committer = \'%s\'\n' % vcs_info.committer)
f.write('git_status = \'%s\'\n' % vcs_info.status)
f.write('git_builder = \'%s\'\n' % vcs_info.builder)
f.write('git_build_date = \'%s\'\n' % vcs_info.build_date)
f.write('git_verbose_msg = """Branch: %s\n'
'Tag: %s\n'
'Id: %s\n'
'Builder: %s\n'
'Build date: %s\n'
'Repository status is %s"""' %(vcs_info.branch,
vcs_info.tag,
vcs_info.hash,
vcs_info.builder,
vcs_info.build_date,
vcs_info.status))
version = vcs_info.version
# If this is a release or another kind of source distribution of PyCBC
except:
version = '1.2.dev0'
release = 'False'
date = hash = branch = tag = author = committer = status = builder = build_date = ''
with open('pycbc/version.py', 'w') as f:
f.write("# Generated by setup.py for PyCBC.\n\n")
# print general infov
f.write('version = \'%s\'\n' % version)
f.write('date = \'%s\'\n' % date)
f.write('release = %s\n' % release)
# print git info
f.write('\ngit_hash = \'%s\'\n' % hash)
f.write('git_branch = \'%s\'\n' % branch)
f.write('git_tag = \'%s\'\n' % tag)
f.write('git_author = \'%s\'\n' % author)
f.write('git_committer = \'%s\'\n' % committer)
f.write('git_status = \'%s\'\n' % status)
f.write('git_builder = \'%s\'\n' % builder)
f.write('git_build_date = \'%s\'\n' % build_date)
f.write('git_verbose_msg = """Version: %s Release: %s \n'
' """' % (version, release))
from pycbc import version
version = version.version
return version
class build_docs(Command):
user_options = []
description = "Build the documentation pages"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
subprocess.check_call("cd docs; cp Makefile.std Makefile; cp conf_std.py conf.py; sphinx-apidoc "
" -o ./ -f -A 'PyCBC dev team' -V '0.1' ../pycbc && make html",
stderr=subprocess.STDOUT, shell=True)
class build_gh_pages(Command):
user_options = []
description = "Build the documentation pages for GitHub"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
subprocess.check_call("cd docs; cp Makefile.gh_pages Makefile; cp conf_std.py conf.py; sphinx-apidoc "
" -o ./ -f -A 'PyCBC dev team' -V '0.1' ../pycbc && make html",
stderr=subprocess.STDOUT, shell=True)
class build_docs_test(Command):
user_options = []
description = "Build the documentation pages in testing mode"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
subprocess.check_call("cd docs; cp Makefile.std Makefile; cp conf_test.py conf.py; sphinx-apidoc "
" -o ./ -f -A 'PyCBC dev team' -V '0.1' ../pycbc && make html",
stderr=subprocess.STDOUT, shell=True)
cmdclass = { 'test' : test,
'build_docs' : build_docs,
'build_gh_pages' : build_gh_pages,
'build_docs_test' : build_docs_test,
'install' : install,
'test_cpu':test_cpu,
'test_cuda':test_cuda,
'clean' : clean,
}
extras_require = {'cuda': ['pycuda>=2015.1', 'scikit-cuda']}
# do the actual work of building the package
VERSION = get_version_info()
setup (
name = 'PyCBC',
version = VERSION,
description = 'Gravitational wave CBC analysis toolkit',
author = 'Ligo Virgo Collaboration - PyCBC team',
author_email = '[email protected]',
url = 'https://github.com/ligo-cbc/pycbc',
download_url = 'https://github.com/ligo-cbc/pycbc/tarball/v%s' % VERSION,
keywords = ['ligo', 'physics', 'gravity', 'signal processing'],
cmdclass = cmdclass,
setup_requires = setup_requires,
extras_require = extras_require,
install_requires = install_requires,
dependency_links = links,
scripts = [
'bin/minifollowups/pycbc_single_template_plot',
'bin/minifollowups/pycbc_page_coincinfo',
'bin/minifollowups/pycbc_plot_trigger_timeseries',
'bin/lalapps/lalapps_inspiral_ahope',
'bin/lalapps/lalapps_tmpltbank_ahope',
'bin/pycbc_banksim',
'bin/pycbc_faithsim',
'bin/pycbc_inspiral',
'bin/pycbc_single_template',
'bin/pycbc_multi_inspiral',
'bin/pycbc_make_banksim',
'bin/pycbc_splitbank',
'bin/pycbc_split_inspinj',
'bin/pycbc_geom_aligned_2dstack',
'bin/pycbc_geom_aligned_bank',
'bin/pycbc_geom_nonspinbank',
'bin/pycbc_aligned_bank_cat',
'bin/pycbc_aligned_stoch_bank',
'bin/pycbc_make_faithsim',
'bin/pycbc_get_ffinal',
'bin/pycbc_timeslides',
'bin/pycbc_sqlite_simplify',
'bin/pycbc_calculate_far',
'bin/pycbc_compute_durations',
'bin/pycbc_pipedown_plots',
'bin/pycbc_tmpltbank_to_chi_params',
'bin/pycbc_bank_verification',
'bin/pycbc_run_sqlite',
'bin/pycbc_inspinjfind',
'bin/pycbc_write_results_page',
'bin/pycbc_upload_xml_to_gracedb',
'bin/pycbc_add_fref_to_sim_inspiral_table',
'bin/gstlal/pycbc_calculate_likelihood',
'bin/gstlal/pycbc_combine_likelihood',
'bin/gstlal/pycbc_compute_far_from_snr_chisq_histograms',
'bin/gstlal/pycbc_gen_ranking_data',
'bin/gstlal/pycbc_pickle_horizon_distances',
'bin/pycbc_make_coinc_workflow',
'bin/pycbc_make_html_page',
'bin/pycbc_ligolw_find_playground',
'bin/hdfcoinc/pycbc_make_hdf_coinc_workflow',
'bin/hdfcoinc/pycbc_make_psd_estimation_workflow',
'bin/hdfcoinc/pycbc_calculate_psd',
'bin/hdfcoinc/pycbc_average_psd',
'bin/pycbc_optimal_snr',
'bin/pycbc_fit_sngl_trigs',
'bin/pycbc_make_nr_hdf_catalog',
'bin/hdfcoinc/pycbc_coinc_mergetrigs',
'bin/hdfcoinc/pycbc_coinc_findtrigs',
'bin/hdfcoinc/pycbc_coinc_bank2hdf',
'bin/hdfcoinc/pycbc_coinc_trig2hdf',
'bin/hdfcoinc/pycbc_coinc_statmap',
'bin/hdfcoinc/pycbc_coinc_statmap_inj',
'bin/hdfcoinc/pycbc_page_foreground',
'bin/hdfcoinc/pycbc_page_foundmissed',
'bin/hdfcoinc/pycbc_page_ifar',
'bin/hdfcoinc/pycbc_page_snrifar',
'bin/hdfcoinc/pycbc_page_sensitivity',
'bin/hdfcoinc/pycbc_page_banktriggerrate',
'bin/hdfcoinc/pycbc_coinc_hdfinjfind',
'bin/hdfcoinc/pycbc_page_snrchi',
'bin/hdfcoinc/pycbc_page_segments',
'bin/hdfcoinc/pycbc_page_segtable',
'bin/hdfcoinc/pycbc_page_segplot',
'bin/hdfcoinc/pycbc_page_vetotable',
'bin/hdfcoinc/pycbc_plot_psd_file',
'bin/hdfcoinc/pycbc_plot_range',
'bin/hdfcoinc/pycbc_foreground_censor',
'bin/hdfcoinc/pycbc_plot_hist',
'bin/hdfcoinc/pycbc_page_recovery',
'bin/hwinj/pycbc_generate_hwinj',
'bin/hwinj/pycbc_generate_hwinj_from_xml',
'bin/hwinj/pycbc_plot_hwinj',
'bin/hwinj/pycbc_insert_frame_hwinj',
'bin/hdfcoinc/pycbc_strip_injections',
'bin/sngl/pycbc_ligolw_cluster',
'bin/sngl/pycbc_plot_bank',
'bin/sngl/pycbc_plot_glitchgram',
'bin/sngl/pycbc_plot_histogram',
'bin/sngl/pycbc_plot_params',
'bin/sngl/pycbc_plot_rates',
'bin/sngl/pycbc_plot_timeseries',
'bin/hdfcoinc/pycbc_page_injtable',
'bin/pycbc_submit_dax',
'bin/pycbc_submit_dax_stampede',
'bin/hdfcoinc/pycbc_page_coinc_snrchi',
'bin/hdfcoinc/pycbc_distribute_background_bins',
'bin/hdfcoinc/pycbc_combine_statmap',
'bin/hdfcoinc/pycbc_stat_dtphase',
'bin/hdfcoinc/pycbc_plot_singles_vs_params',
'bin/hdfcoinc/pycbc_plot_singles_timefreq',
'bin/mvsc/pycbc_mvsc_get_features',
'bin/pycbc_coinc_time',
'bin/hdfcoinc/pycbc_plot_background_coincs',
'bin/hdfcoinc/pycbc_plot_bank_bins',
'bin/pygrb/pygrb_make_offline_workflow',
'bin/pygrb/pygrb_make_summary_page',
],
packages = [
'pycbc',
'pycbc.fft',
'pycbc.types',
'pycbc.filter',
'pycbc.psd',
'pycbc.waveform',
'pycbc.events',
'pycbc.noise',
'pycbc.vetoes',
'pycbc.tmpltbank',
'pycbc.workflow',
'pycbc.results',
'pycbc.io',
],
package_data = {'pycbc.workflow': find_package_data('pycbc/workflow'),
'pycbc.results': find_package_data('pycbc/results'),
'pycbc.tmpltbank': find_package_data('pycbc/tmpltbank')},
)