55import os .path
66import warnings
77
8- try :
9- from setuptools import setup , Extension
10- from setuptools .dist import Distribution
11- requires = {
12- "install_requires" : ["numpy" ],
13- "setup_requires" : ["numpy" ]
14- }
15- except ImportError :
16- from distutils .core import setup
17- from distutils .dist import Distribution
18- from distutils .extension import Extension
19- requires = {"requires" : ["numpy" ]}
8+ from setuptools import setup , Extension
9+ from setuptools .dist import Distribution
2010
2111platform_supported = False
2212
8373 warnings .warn ('Cannot find ta-lib library, installation may fail.' )
8474
8575
86- class LazyBuildExtCommandClass (dict ):
87- """
88- Lazy command class that defers operations requiring Cython and numpy until
89- they've actually been downloaded and installed by setup_requires.
90- """
91-
92- def __contains__ (self , key ):
93- return (key == 'build_ext' or
94- super (LazyBuildExtCommandClass , self ).__contains__ (key ))
95-
96- def __setitem__ (self , key , value ):
97- if key == 'build_ext' :
98- raise AssertionError ("build_ext overridden!" )
99- super (LazyBuildExtCommandClass , self ).__setitem__ (key , value )
100-
101- def __getitem__ (self , key ):
102- if key != 'build_ext' :
103- return super (LazyBuildExtCommandClass , self ).__getitem__ (key )
76+ import numpy
10477
105- import numpy
106- if has_cython :
107- org_build_ext = cython_build_ext
108- else :
109- from setuptools .command .build_ext import build_ext as org_build_ext
110-
111- # Cython_build_ext isn't a new-style class in Py2.
112- class build_ext (org_build_ext , object ):
113- """
114- Custom build_ext command that lazily adds numpy's include_dir to
115- extensions.
116- """
117-
118- def build_extensions (self ):
119- """
120- Lazily append numpy's include directory to Extension includes.
121- This is done here rather than at module scope because setup.py
122- may be run before numpy has been installed, in which case
123- importing numpy and calling `numpy.get_include()` will fail.
124- """
125- numpy_incl = numpy .get_include ()
126- for ext in self .extensions :
127- ext .include_dirs .append (numpy_incl )
78+ # Get the Cython build_ext or fall back to setuptools build_ext
79+ if has_cython :
80+ from Cython .Distutils import build_ext
81+ else :
82+ from setuptools .command .build_ext import build_ext
12883
129- super (build_ext , self ).build_extensions ()
84+ class NumpyBuildExt (build_ext ):
85+ """
86+ Custom build_ext command that adds numpy's include_dir to extensions.
87+ """
13088
131- return build_ext
89+ def build_extensions (self ):
90+ """
91+ Add numpy's include directory to Extension includes.
92+ """
93+ numpy_incl = numpy .get_include ()
94+ for ext in self .extensions :
95+ ext .include_dirs .append (numpy_incl )
13296
97+ super ().build_extensions ()
13398
134- cmdclass = LazyBuildExtCommandClass ()
99+ cmdclass = { 'build_ext' : NumpyBuildExt }
135100
136101ext_modules = [
137102 Extension (
@@ -143,53 +108,7 @@ def build_extensions(self):
143108 runtime_library_dirs = [] if sys .platform == 'win32' else library_dirs )
144109]
145110
146- from os import path
147- this_directory = path .abspath (path .dirname (__file__ ))
148- with open (path .join (this_directory , 'README.md' ), encoding = 'utf-8' ) as f :
149- long_description = f .read ()
150-
151111setup (
152- name = 'TA-Lib' ,
153- version = '0.6.4' ,
154- description = 'Python wrapper for TA-Lib' ,
155- long_description = long_description ,
156- long_description_content_type = 'text/markdown' ,
157- author = 'John Benediktsson' ,
158- 159- url = 'http://github.com/ta-lib/ta-lib-python' ,
160- download_url = 'https://github.com/ta-lib/ta-lib-python/releases' ,
161- license = "BSD" ,
162- classifiers = [
163- "Development Status :: 5 - Production/Stable" ,
164- "Operating System :: Unix" ,
165- "Operating System :: POSIX" ,
166- "Operating System :: MacOS :: MacOS X" ,
167- "Operating System :: Microsoft :: Windows" ,
168- "Programming Language :: Python" ,
169- "Programming Language :: Python :: 2" ,
170- "Programming Language :: Python :: 2.7" ,
171- "Programming Language :: Python :: 3" ,
172- "Programming Language :: Python :: 3.3" ,
173- "Programming Language :: Python :: 3.4" ,
174- "Programming Language :: Python :: 3.5" ,
175- "Programming Language :: Python :: 3.6" ,
176- "Programming Language :: Python :: 3.7" ,
177- "Programming Language :: Python :: 3.8" ,
178- "Programming Language :: Python :: 3.9" ,
179- "Programming Language :: Python :: 3.10" ,
180- "Programming Language :: Python :: 3.11" ,
181- "Programming Language :: Python :: 3.12" ,
182- "Programming Language :: Python :: 3.13" ,
183- "Programming Language :: Python :: 3.14" ,
184- "Programming Language :: Cython" ,
185- "Topic :: Office/Business :: Financial" ,
186- "Topic :: Scientific/Engineering :: Mathematics" ,
187- "Intended Audience :: Developers" ,
188- "Intended Audience :: Science/Research" ,
189- "Intended Audience :: Financial and Insurance Industry" ,
190- ],
191- packages = ['talib' ],
192112 ext_modules = ext_modules ,
193- package_data = { 'talib' : ['_ta_lib.pyi' , 'py.typed' ], },
194113 cmdclass = cmdclass ,
195- ** requires )
114+ )
0 commit comments