forked from GeoStat-Framework/PyKrige
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·151 lines (125 loc) · 5.78 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
from __future__ import absolute_import
from __future__ import print_function
"""
Updated BSM 10/23/2015
Cython extensions work-around adapted from simplejson setup script:
https://github.com/simplejson/simplejson/blob/0bcdf20cc525c1343b796cb8f247ea5213c6557e/setup.py#L110
"""
import sys
from os.path import join
from setuptools import setup, Extension
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
NAME = 'PyKrige'
VERSION = '1.4.0'
AUTHOR = 'Benjamin S. Murphy'
EMAIL = '[email protected]'
URL = 'https://github.com/bsmurphy/PyKrige'
DESC = 'Kriging Toolkit for Python'
with open('README.rst', 'r') as fh:
LDESC = fh.read()
PACKAGES = ['pykrige']
PCKG_DAT = {'pykrige': ['README.rst', 'CHANGELOG.md', 'LICENSE.txt',
'MANIFEST.in', join('test_data', '*.txt'),
join('test_data', '*.asc')]}
min_numpy_ver = '1.14.0'
min_scipy_ver = '1.0.0'
min_matplotlib_ver = '2.0.0'
setuptools_kwargs = {
'install_requires': [
'numpy >= {numpy_ver}'.format(numpy_ver=min_numpy_ver),
'scipy >= {scipy_ver}'.format(scipy_ver=min_scipy_ver),
'matplotlib >= {matplotlib_ver}'.format(matplotlib_ver=min_matplotlib_ver),
],
'setup_requires': ['numpy >= {numpy_ver}'.format(numpy_ver=min_numpy_ver)],
}
min_cython_ver = '0.28.2'
CLSF = ['Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: GIS']
# Removed python 3 switch from here
try:
from Cython.Distutils import build_ext
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = False
try_cython = True
except ImportError:
print("**************************************************")
print("WARNING: Cython is not currently installed. "
"Falling back to pure Python implementation.")
print("**************************************************")
try_cython = False
class BuildFailed(Exception):
pass
# This is how I was originally trying to get around the
# Cython extension troubles... Keeping it here for reference...
#
# class BuildExtCompilerCheck(build_ext):
# def build_extensions(self):
# if sys.platform == 'win32' and ('MSC' in sys.version or 'MSVC' in sys.version):
# print("-> COMPILER IS", self.compiler.compiler_type)
# from distutils.msvccompiler import MSVCCompiler
# if isinstance(self.compiler, MSVCCompiler):
# build_ext.build_extensions(self)
# else:
# print("WARNING: The C extensions will not be built since the necessary compiler could not be found.\n"
# "See https://github.com/bsmurphy/PyKrige/issues/8")
# else:
# build_ext.build_extensions(self)
def run_setup(with_cython):
if with_cython:
import numpy as np
if sys.platform != 'win32':
compile_args = dict(extra_compile_args=['-O2', '-march=core2',
'-mtune=corei7'],
extra_link_args=['-O2', '-march=core2',
'-mtune=corei7'])
else:
compile_args = {}
ext_modules = [Extension("pykrige.lib.cok",
["pykrige/lib/cok.pyx"],
**compile_args),
Extension("pykrige.lib.variogram_models",
["pykrige/lib/variogram_models.pyx"],
**compile_args)]
# Transfered python 3 switch here.
# On python 3 machines, will use lapack_py3.pyx
# instead of lapack.pyx to build .lib.lapack
if sys.version_info[0] == 3:
ext_modules += [Extension("pykrige.lib.lapack",
["pykrige/lib/lapack_py3.pyx"],
**compile_args)]
else:
ext_modules += [Extension("pykrige.lib.lapack",
["pykrige/lib/lapack.pyx"],
**compile_args)]
class TryBuildExt(build_ext):
def build_extensions(self):
try:
build_ext.build_extensions(self)
except ext_errors:
print("**************************************************")
print("WARNING: Cython extensions failed to build. "
"Falling back to pure Python implementation.\n"
"See https://github.com/bsmurphy/PyKrige/issues/8 "
"for more information.")
print("**************************************************")
raise BuildFailed()
cmd = {'build_ext': TryBuildExt}
setup(name=NAME, version=VERSION, author=AUTHOR, author_email=EMAIL,
url=URL, description=DESC, long_description=LDESC,
packages=PACKAGES, package_data=PCKG_DAT, classifiers=CLSF,
ext_modules=ext_modules, include_dirs=[np.get_include()],
cmdclass=cmd,**setuptools_kwargs)
else:
setup(name=NAME, version=VERSION, author=AUTHOR, author_email=EMAIL,
url=URL, description=DESC, long_description=LDESC,
packages=PACKAGES, package_data=PCKG_DAT, classifiers=CLSF,
**setuptools_kwargs)
try:
run_setup(try_cython)
except BuildFailed:
run_setup(False)