Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
108 lines (90 loc) · 2.69 KB
/
Copy pathsetup.py
File metadata and controls
108 lines (90 loc) · 2.69 KB
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
#!/usr/bin/env python
importsys
importos
importos.path
importwarnings
fromsetuptoolsimportsetup, Extension
importnumpy
platform_supported=False
lib_talib_name='ta-lib'# the name as of TA-Lib 0.6.1
ifany(sinsys.platformforsin ['darwin', 'linux', 'bsd', 'sunos']):
platform_supported=True
include_dirs= [
'/usr/include',
'/usr/local/include',
'/opt/include',
'/opt/local/include',
'/opt/homebrew/include',
'/opt/homebrew/opt/ta-lib/include',
]
library_dirs= [
'/usr/lib',
'/usr/local/lib',
'/usr/lib64',
'/usr/local/lib64',
'/opt/lib',
'/opt/local/lib',
'/opt/homebrew/lib',
'/opt/homebrew/opt/ta-lib/lib',
]
elifsys.platform=="win32":
platform_supported=True
lib_talib_name='ta-lib-static'
include_dirs= [
r"c:\ta-lib\c\include",
r"c:\Program Files\TA-Lib\include",
r"c:\Program Files (x86)\TA-Lib\include",
]
library_dirs= [
r"c:\ta-lib\c\lib",
r"c:\Program Files\TA-Lib\lib",
r"c:\Program Files (x86)\TA-Lib\lib",
]
if'TA_INCLUDE_PATH'inos.environ:
include_dirs=os.environ['TA_INCLUDE_PATH'].split(os.pathsep)
if'TA_LIBRARY_PATH'inos.environ:
library_dirs=os.environ['TA_LIBRARY_PATH'].split(os.pathsep)
ifnotplatform_supported:
raiseNotImplementedError(sys.platform)
forpathinlibrary_dirs:
try:
files=os.listdir(path)
ifany(lib_talib_nameinfforfinfiles):
break
exceptOSError:
pass
else:
warnings.warn('Cannot find ta-lib library, installation may fail.')
# Get the Cython build_ext or fall back to setuptools build_ext
try:
fromCython.Distutilsimportbuild_ext
has_cython=True
exceptImportError:
fromsetuptools.command.build_extimportbuild_ext
has_cython=False
classNumpyBuildExt(build_ext):
"""
Custom build_ext command that adds numpy's include_dir to extensions.
"""
defbuild_extensions(self):
"""
Add numpy's include directory to Extension includes.
"""
numpy_incl=numpy.get_include()
forextinself.extensions:
ext.include_dirs.append(numpy_incl)
super().build_extensions()
cmdclass= {'build_ext': NumpyBuildExt}
ext_modules= [
Extension(
'talib._ta_lib',
['talib/_ta_lib.pyx'ifhas_cythonelse'talib/_ta_lib.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=[lib_talib_name],
runtime_library_dirs=[] ifsys.platform=='win32'elselibrary_dirs)
]
setup(
ext_modules=ext_modules,
cmdclass=cmdclass,
)