Skip to content

Commit 0efbbfa

Browse files
dont require cython
1 parent 0bd5d93 commit 0efbbfa

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

setup.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66

77
from distutils.dist import Distribution
88

9-
# display_option_names = Distribution.display_option_names + ['help', 'help-commands']
10-
# query_only = any('--' + opt in sys.argv for opt in display_option_names) or len(sys.argv) < 2 or sys.argv[1] == 'egg_info'
11-
129
try:
1310
from setuptools import setup, Extension
14-
requires = {
15-
"install_requires": ["numpy", 'cython'],
16-
"setup_requires": ['numpy', 'cython']
17-
}
11+
requires = {"install_requires": ["numpy"], "setup_requires": ["numpy"]}
1812
except:
1913
from distutils.core import setup
2014
from distutils.extension import Extension
@@ -60,16 +54,11 @@
6054
if not platform_supported:
6155
raise NotImplementedError(sys.platform)
6256

63-
# # Do not require numpy or cython for just querying the package
64-
# if not query_only:
65-
# import numpy
66-
# include_dirs.insert(0, numpy.get_include())
67-
#
68-
# try:
69-
# from Cython.Distutils import build_ext
70-
# has_cython = True
71-
# except ImportError:
72-
# has_cython = False
57+
try:
58+
from Cython.Distutils import build_ext as cython_build_ext
59+
has_cython = True
60+
except ImportError:
61+
has_cython = False
7362

7463
for lib_talib_dir in lib_talib_dirs:
7564
try:
@@ -81,10 +70,6 @@
8170
else:
8271
warnings.warn('Cannot find ta-lib library, installation may fail.')
8372

84-
# cmdclass = {}
85-
# if has_cython:
86-
# cmdclass['build_ext'] = build_ext
87-
8873

8974
class LazyBuildExtCommandClass(dict):
9075
"""
@@ -106,11 +91,14 @@ def __getitem__(self, key):
10691
if key != 'build_ext':
10792
return super(LazyBuildExtCommandClass, self).__getitem__(key)
10893

109-
from Cython.Distutils import build_ext as cython_build_ext
11094
import numpy
95+
if has_cython:
96+
org_build_ext = cython_build_ext
97+
else:
98+
from setuptools.command.build_ext import build_ext as org_build_ext
11199

112100
# Cython_build_ext isn't a new-style class in Py2.
113-
class build_ext(cython_build_ext, object):
101+
class build_ext(org_build_ext, object):
114102
"""
115103
Custom build_ext command that lazily adds numpy's include_dir to
116104
extensions.
@@ -137,7 +125,7 @@ def build_extensions(self):
137125
ext_modules = [
138126
Extension(
139127
'talib._ta_lib',
140-
['talib/_ta_lib.pyx'], # if has_cython else 'talib/_ta_lib.c'],
128+
['talib/_ta_lib.pyx' if has_cython else 'talib/_ta_lib.c'],
141129
include_dirs=include_dirs,
142130
library_dirs=lib_talib_dirs,
143131
libraries=[lib_talib_name],

0 commit comments

Comments
 (0)