-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
86 lines (71 loc) · 2.54 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
import sys
import textwrap
import pkg_resources
from setuptools import Extension, find_packages, setup
from setuptools.command.build_py import build_py as _build_py
class build_py(_build_py):
def run(self):
self.run_command("build_ext")
return super().run()
with open("README.md") as f:
readme = f.read()
try:
pkg_resources.require("setuptools >= 18.0")
except pkg_resources.ResolutionError:
print(
textwrap.dedent(
"""
setuptools >= 18.0 is required, and the dependency cannot be
automatically resolved with the version of setuptools that is
currently installed (%s).
You can upgrade setuptools:
$ pip install -U setuptools
"""
% pkg_resources.get_distribution("setuptools").version
),
file=sys.stderr,
)
sys.exit(1)
# Here we try to import Cython - if it's here then we can generate new c sources
# directly from the pyx files using their build_ext class.
# If not then we just use the default setuptools version
try:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
HAVE_CYTHON = True
except ImportError:
from setuptools.command.build_ext import build_ext
# from distutils.command.build_ext import build_ext
HAVE_CYTHON = False
# setting this flag to false for distribution
HAVE_CYTHON = False
# Get extensions and update command class
# CMDCLASS = {
# 'build_ext': build_ext
# }
extensions = {}
ext = ".pyx" if HAVE_CYTHON else ".c"
extensions = [Extension("csiro_spectral_tools.ext.chulls", ["csiro_spectral_tools/ext/chulls" + ext])]
if HAVE_CYTHON:
# extensions = [Extension("spex.ext.chulls", ["spex/ext/chulls.pyx"])]
compiler_directives = {"language_level": 3, "embedsignature": True}
extensions = cythonize(extensions, compiler_directives=compiler_directives)
setup(
name="csiro-spectral-tools",
version="0.2.1",
packages=find_packages(),
package_data={"csiro_spectral_tools": ["ext/*.pyd", "ext/*.so"]},
include_package_data=True,
url="https://github.com/CSIRO-GeoscienceAnalytics/spectral-tools",
author="Andrew Rodger",
license="MIT",
description="A collection of tools used for working with hyperspectral data",
long_description=readme,
install_requires=["numpy", "spectral", "pandas", "scipy", "scikit-learn"],
python_requires=">=3.8",
setup_requires=["numpy", "wheel"],
zip_safe=False,
# Cython extensions & other stuff
cmdclass={"build_py": build_py, "build_ext": build_ext},
ext_modules=extensions,
)