-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
110 lines (96 loc) · 2.75 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
"""
Build with:
python setup.py build_ext --inplace
See this site for building on windows-64:
https://github.com/cython/cython/wiki/CythonExtensionsOnWindows
See this example for packaging cython modules:
https://github.com/thearn/simple-cython-example/blob/master/setup.py
"""
#from distutils.core import setup
#from distutils.extension import Extension
try:
from setuptools import setup
from setuptools import Extension
from setuptools.dist import Distribution
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
class BinaryDistribution(Distribution):
def is_pure(self):
return False
try:
from Cython.Build import cythonize
use_cython = True
ext = 'pyx'
except:
use_cython = False
ext = 'c'
#from Cython.Distutils import build_ext
import os
import numpy
# Check for a C compiler
import distutils.ccompiler
if isinstance(distutils.ccompiler.new_compiler(), distutils.ccompiler.CCompiler):
compile=True
else:
compile=False
if compile:
os.environ["CC"]='cc'
extensions =[
Extension("sfoda.ugrid.ugridutils",["sfoda/ugrid/ugridutils.{}".format(ext)],
include_dirs=[numpy.get_include()],
extra_compile_args=
['-shared', '-pthread', '-fPIC', '-fwrapv', '-O2', '-Wall',
'-fno-strict-aliasing'],),
Extension("sfoda.ugrid.searchutils",["sfoda/ugrid/searchutils.{}".format(ext)],
include_dirs=[numpy.get_include()],
extra_compile_args=['-O3','-ffast-math','-march=native','-fopenmp'],
extra_link_args=['-fopenmp'],),
]
if use_cython:
ext_modules = cythonize(extensions, language_level=3)
cmdclass = {}
else:
cmdclass= {} #{"build_ext": extensions}
ext_modules = extensions
else:
cmdclass = {}
ext_modules = None
setup(
name = "sfoda",
packages=[
'sfoda',
'sfoda.utils',
'sfoda.ugrid',
'sfoda.suntans',
'sfoda.roms',
'sfoda.tides',
'sfoda.dbase',
'sfoda.dataio.conversion',
'sfoda.dataio.datadownload',
],
#package_dir={'sfoda':''},
ext_modules = ext_modules,
cmdclass = cmdclass,
version="0.1.3",
description='Stuff For Ocean Data Analysis',
author='Matt Rayson',
author_email='[email protected]',
#packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
install_requires=[
'numpy>=1.20.0',
'scipy',
'matplotlib',
'netcdf4',
'xarray',
'pyyaml',
#'numba',
'pyproj',
'dask[complete]',
#'gdal',
#'shapely',
],
license='LICENSE',
include_package_data=True,
distclass=BinaryDistribution,
)