forked from dstndstn/tractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
119 lines (103 loc) · 3.94 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
from distutils.core import setup, Extension
from distutils.command.build_ext import *
from distutils.dist import Distribution
import os
# from http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
from distutils.command.build import build
class CustomBuild(build):
sub_commands = [
('build_ext', build.has_ext_modules),
('build_py', build.has_pure_modules),
('build_clib', build.has_c_libraries),
('build_scripts', build.has_scripts),
]
import numpy as np
numpy_inc = [np.get_include()]
import sys
from subprocess import check_output
eigen_inc = os.environ.get('EIGEN_INC', None)
if eigen_inc is None:
try:
eigen_inc = check_output(['pkg-config', '--cflags', 'eigen3']).strip()
# py3
eigen_inc = eigen_inc.decode()
except:
eigen_inc = ''
inc = eigen_inc.split()
ceres_inc = os.environ.get('CERES_INC', None)
ceres_lib = os.environ.get('CERES_LIB', None)
if ceres_inc is not None:
inc.append(ceres_inc)
link = []
if ceres_lib is not None:
link.append(ceres_lib)
module_ceres = Extension('tractor._ceres',
sources=['tractor/ceres-tractor.cc', 'tractor/ceres.i'],
include_dirs = numpy_inc,
extra_compile_args = inc,
extra_link_args = link,
language = 'c++',
swig_opts=['-c++'],
)
module_mix = Extension('tractor._mix',
sources = ['tractor/mix.i'],
include_dirs = numpy_inc,
extra_objects = [],
undef_macros=['NDEBUG'],
)
#extra_compile_args=['-O0','-g'],
#extra_link_args=['-O0', '-g'],
module_em = Extension('tractor._emfit',
sources = ['tractor/emfit.i' ],
include_dirs = numpy_inc,
extra_objects = [],
undef_macros=['NDEBUG'],
)
kwargs = {}
if os.environ.get('CC') == 'icc':
kwargs.update(extra_compile_args=['-g', '-xhost', '-axMIC-AVX512'],
extra_link_args=['-g', '-lsvml'])
else:
kwargs.update(extra_compile_args=['-g', '-std=c99'],
extra_link_args=['-g'])
module_fourier = Extension('tractor._mp_fourier',
sources = ['tractor/mp_fourier.i'],
include_dirs = numpy_inc,
undef_macros=['NDEBUG'],
**kwargs)
class MyDistribution(Distribution):
display_options = Distribution.display_options + [
('with-ceres', None, 'build Ceres module?'),
]
## Distutils is so awkward to work with that THIS is the easiest way to add
# an extra command-line arg!
mods = [module_mix, module_em, module_fourier]
pymods = ['tractor.mix', 'tractor.emfit', 'tractor.mp_fourier']
key = '--with-ceres'
if key in sys.argv:
sys.argv.remove(key)
mods.append(module_ceres)
pymods.append('tractor.ceres')
setup(
distclass=MyDistribution,
cmdclass={'build': CustomBuild},
name="tractor",
version="git",
author="Dustin Lang (UToronto) and David W. Hogg (NYU)",
author_email="[email protected]",
packages=['tractor', 'wise'],
ext_modules = mods,
package_data={'wise':['wise-psf-avg.fits', 'allsky-atlas.fits']},
package_dir={'wise':'wise', 'tractor':'tractor'},
url="http://theTractor.org/",
license="GPLv2",
description="probabilistic astronomical image analysis",
long_description="Attempt at replacing heuristic astronomical catalogs with models built with specified likelihoods, priors, and utilities.",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Programming Language :: Python",
],
)