forked from pyrocko/kite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
172 lines (158 loc) · 5.22 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
#!/usr/bin/env python
import os
import tempfile
from setuptools import setup, Extension
from os.path import join as pjoin
try:
import numpy
except ImportError:
class numpy():
def __init__(self):
pass
@classmethod
def get_include(self):
return ''
version = '2017.11'
def _check_for_openmp():
"""Check whether the default compiler supports OpenMP.
This routine is adapted from pynbody // yt.
Thanks to Nathan Goldbaum and Andrew Pontzen.
"""
import distutils.sysconfig
import subprocess
import shutil
tmpdir = tempfile.mkdtemp(prefix='kite')
compiler = os.environ.get(
'CC', distutils.sysconfig.get_config_var('CC')).split()[0]
# Attempt to compile a test script.
# See http://openmp.org/wp/openmp-compilers/
tmpfile = pjoin(tmpdir, 'check_openmp.c')
with open(tmpfile, 'w') as f:
f.write('''
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d", omp_get_thread_num());
}
''')
try:
with open(os.devnull, 'w') as fnull:
exit_code = subprocess.call([compiler, '-fopenmp', '-o%s'
% pjoin(tmpdir, 'check_openmp'),
tmpfile],
stdout=fnull, stderr=fnull)
except OSError:
exit_code = 1
finally:
shutil.rmtree(tmpdir)
if exit_code == 0:
print ('Continuing your build using OpenMP...\n')
return True
import multiprocessing
import platform
if multiprocessing.cpu_count() > 1:
print('''WARNING
OpenMP support is not available in your default C compiler, even though
your machine has more than one core available.
Some routines in kite are parallelized using OpenMP and these will
only run on one core with your current configuration.
''')
if platform.uname()[0] == 'Darwin':
print('''Since you are running on Mac OS, it's likely that the problem here
is Apple's Clang, which does not support OpenMP at all. The easiest
way to get around this is to download the latest version of gcc from
here: http://hpc.sourceforge.net. After downloading, just point the
CC environment variable to the real gcc and OpenMP support should
get enabled automatically. Something like this -
sudo tar -xzf /path/to/download.tar.gz /
export CC='/usr/local/bin/gcc'
python setup.py clean
python setup.py build
''')
print ('Continuing your build without OpenMP...\n')
return False
if _check_for_openmp():
omp_arg = ['-fopenmp']
omp_lib = ['-lgomp']
else:
omp_arg = []
omp_lib = []
setup(
name='kite',
version=version,
description='Handle SAR displacement data towards pyrocko',
author='Marius P. Isken, Henriette Sudhaus;'
'BriDGes Emmily Noether-Programm (DFG)',
author_email='[email protected]',
license='GPLv3',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Atmospheric Science',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Visualization',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: C',
'Operating System :: POSIX',
'Operating System :: MacOS',
],
keywords=[
'insar satellite radar earthquake optimization'],
install_requires=[
'numpy>=1.8.0', 'pyrocko', 'scipy', 'pyyaml',
'progressbar', 'utm', 'pyqtgraph>=0.10.0'],
packages=[
'kite',
'kite.sources',
'kite.spool',
'kite.talpa',
'kite.talpa.sources'],
package_dir={
'kite': 'src'},
package_data={
'kite': ['spool/res/*',
'talpa/res/*']},
entry_points={
'console_scripts':
['spool = kite.spool.__main__:main',
'talpa = kite.talpa.__main__:main']},
ext_package='kite',
ext_modules=[
Extension(
'covariance_ext',
sources=[pjoin('src/ext', 'covariance.c')],
include_dirs=[numpy.get_include()],
define_macros=None,
undef_macros=None,
library_dirs=None,
libraries=None,
runtime_library_dirs=None,
extra_objects=None,
extra_compile_args=[] + omp_arg,
extra_link_args=[] + omp_lib,
export_symbols=None,
swig_opts=None,
depends=None,
language=None),
Extension(
'sources.disloc_ext',
sources=[pjoin('src/sources/ext', 'disloc.c')],
include_dirs=[numpy.get_include()],
define_macros=None,
undef_macros=None,
library_dirs=None,
libraries=None,
runtime_library_dirs=None,
extra_objects=None,
extra_compile_args=[] + omp_arg,
extra_link_args=[] + omp_lib,
export_symbols=None,
swig_opts=None,
depends=None,
language=None),
]
)