forked from simonsobs/pixell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
169 lines (148 loc) · 5.44 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""The setup script."""
import setuptools
from distutils.errors import DistutilsError
from numpy.distutils.core import setup, Extension, build_ext, build_src
from distutils.sysconfig import get_config_var, get_config_vars
import versioneer
import os, sys
import subprocess as sp
import numpy as np
build_ext = build_ext.build_ext
build_src = build_src.build_src
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = []
setup_requirements = []
test_requirements = []
# The following copied from healpy might be necessary for libsharp
# Apple switched default C++ standard libraries (from gcc's libstdc++ to
# clang's libc++), but some pre-packaged Python environments such as Anaconda
# are built against the old C++ standard library. Luckily, we don't have to
# actually detect which C++ standard library was used to build the Python
# interpreter. We just have to propagate MACOSX_DEPLOYMENT_TARGET from the
# configuration variables to the environment.
#
# This workaround fixes <https://github.com/healpy/healpy/issues/151>.
if (
get_config_var("MACOSX_DEPLOYMENT_TARGET")
and not "MACOSX_DEPLOYMENT_TARGET" in os.environ
):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = get_config_var("MACOSX_DEPLOYMENT_TARGET")
compile_opts = {
'extra_compile_args': ['-std=c99','-fopenmp', '-Wno-strict-aliasing'],
'extra_f90_compile_args': ['-fopenmp', '-Wno-conversion', '-Wno-tabs'],
'f2py_options': ['skip:', 'map_border', 'calc_weights', ':'],
'extra_link_args': ['-fopenmp']
}
fcflags = os.getenv('FCFLAGS')
if fcflags is None or fcflags.strip() == '':
fcflags = ['-O3']
else:
print('User supplied fortran flags: ', fcflags)
print('These will supersede other optimization flags.')
fcflags = fcflags.split()
compile_opts['extra_f90_compile_args'].extend(fcflags)
def presrc():
# Create f90 files for f2py.
if sp.call('make -C fortran', shell=True) != 0:
raise DistutilsError('Failure in the fortran source-prep step.')
def prebuild():
# Handle the special external dependencies.
if not os.path.exists('_deps/libsharp/libsharp/sharp.h'):
try:
sp.check_call('scripts/install_libsharp.sh', shell=True)
except sp.CalledProcessError:
raise DistutilsError('Failed to install libsharp.')
# Handle cythonization to create sharp.c, etc.
if sp.call('make -C cython', shell=True) != 0:
raise DistutilsError('Failure in the cython pre-build step.')
class CustomBuild(build_ext):
def run(self):
prebuild()
# Then let setuptools do its thing.
return build_ext.run(self)
class CustomSrc(build_src):
def run(self):
presrc()
# Then let setuptools do its thing.
return build_src.run(self)
class CustomEggInfo(setuptools.command.egg_info.egg_info):
def run(self):
presrc()
prebuild()
return setuptools.command.egg_info.egg_info.run(self)
# Cascade your overrides here.
cmdclass = {
'build_ext': CustomBuild,
'build_src': CustomSrc,
'egg_info': CustomEggInfo,
}
cmdclass = versioneer.get_cmdclass(cmdclass)
setup(
author="Simons Observatory Collaboration Analysis Library Task Force",
author_email='',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
description="pixell",
package_dir={"pixell": "pixell"},
entry_points={
# 'console_scripts': [
# 'pixell=pixell.cli:main',
# ],
},
ext_modules=[
Extension('pixell.sharp',
sources=['cython/sharp.c'],
libraries=['sharp','c_utils', 'fftpack'],
library_dirs=['_deps/libsharp/auto/lib'],
include_dirs=[np.get_include()],
**compile_opts),
Extension('pixell._interpol_32',
sources=['fortran/interpol_32.f90'],
**compile_opts),
Extension('pixell._interpol_64',
sources=['fortran/interpol_64.f90'],
**compile_opts),
Extension('pixell._colorize',
sources=['fortran/colorize.f90'],
**compile_opts),
Extension('pixell._array_ops_32',
sources=['fortran/array_ops_32.f90'],
**compile_opts),
Extension('pixell._array_ops_64',
sources=['fortran/array_ops_64.f90'],
**compile_opts),
],
include_dirs = ['_deps/libsharp/auto/include'],
library_dirs = ['_deps/libsharp/auto/lib'],
install_requires=requirements,
license="BSD license",
long_description=readme + '\n\n' + history,
include_package_data=True,
data_files=[('pixell', ['pixell/arial.ttf'])],
keywords='pixell',
name='pixell',
packages=['pixell'],
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/simonsobs/pixell',
version=versioneer.get_version(),
zip_safe=False,
cmdclass=cmdclass
)
print('\n[setup.py request was successful.]')