-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.py
70 lines (55 loc) · 1.63 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
import platform
from pathlib import Path
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
try:
from Cython.Build import cythonize
except:
raise ImportError('Cython must be installed to build GeoWombat.')
try:
import numpy as np
except:
raise ImportError('NumPy must be installed to build GeoWombat.')
compile_args = ['-fopenmp']
link_args = ['-fopenmp']
if platform.system().lower() == 'darwin':
compile_args.insert(0, '-Xpreprocessor')
link_args = ['-lomp']
def get_extensions():
extensions = [
Extension(
'*',
sources=['src/geowombat/moving/_moving.pyx'],
extra_compile_args=compile_args,
extra_link_args=link_args,
)
]
if Path('src/geowombat/moving/_test.pyx').is_file():
extensions += [
Extension(
'*',
sources=['src/geowombat/moving/_test.pyx'],
extra_compile_args=compile_args,
extra_link_args=link_args,
)
]
if Path('src/geowombat/radiometry/_fusion.pyx').is_file():
extensions += [
Extension(
'*',
sources=['src/geowombat/radiometry/_fusion.pyx'],
extra_compile_args=compile_args,
extra_link_args=link_args,
)
]
return extensions
def setup_package():
metadata = dict(
ext_modules=cythonize(get_extensions()), include_dirs=[np.get_include()]
)
setup(**metadata)
if __name__ == '__main__':
setup_package()