|
20 | 20 |
|
21 | 21 | lib_talib_name = 'ta_lib' # the underlying C library's name
|
22 | 22 |
|
23 |
| -runtime_lib_dirs = [] |
24 |
| - |
25 | 23 | platform_supported = False
|
26 |
| -for prefix in ['darwin', 'linux', 'bsd', 'sunos']: |
27 |
| - if prefix in sys.platform: |
28 |
| - platform_supported = True |
29 |
| - include_dirs = [ |
30 |
| - '/usr/include', |
31 |
| - '/usr/local/include', |
32 |
| - '/opt/include', |
33 |
| - '/opt/local/include', |
34 |
| - '/opt/homebrew/include', |
35 |
| - '/opt/homebrew/opt/ta-lib/include', |
36 |
| - ] |
37 |
| - if 'TA_INCLUDE_PATH' in os.environ: |
38 |
| - include_dirs.append(os.environ['TA_INCLUDE_PATH']) |
39 |
| - lib_talib_dirs = [ |
40 |
| - '/usr/lib', |
41 |
| - '/usr/local/lib', |
42 |
| - '/usr/lib64', |
43 |
| - '/usr/local/lib64', |
44 |
| - '/opt/lib', |
45 |
| - '/opt/local/lib', |
46 |
| - '/opt/homebrew/lib', |
47 |
| - '/opt/homebrew/opt/ta-lib/lib', |
48 |
| - ] |
49 |
| - if 'TA_LIBRARY_PATH' in os.environ: |
50 |
| - runtime_lib_dirs = os.environ['TA_LIBRARY_PATH'] |
51 |
| - if runtime_lib_dirs: |
52 |
| - runtime_lib_dirs = runtime_lib_dirs.split(os.pathsep) |
53 |
| - lib_talib_dirs.extend(runtime_lib_dirs) |
54 |
| - break |
55 |
| - |
56 |
| -if sys.platform == "win32": |
| 24 | + |
| 25 | +if any(s in sys.platform for s in ['darwin', 'linux', 'bsd', 'sunos']): |
| 26 | + platform_supported = True |
| 27 | + include_dirs = [ |
| 28 | + '/usr/include', |
| 29 | + '/usr/local/include', |
| 30 | + '/opt/include', |
| 31 | + '/opt/local/include', |
| 32 | + '/opt/homebrew/include', |
| 33 | + '/opt/homebrew/opt/ta-lib/include', |
| 34 | + ] |
| 35 | + library_dirs = [ |
| 36 | + '/usr/lib', |
| 37 | + '/usr/local/lib', |
| 38 | + '/usr/lib64', |
| 39 | + '/usr/local/lib64', |
| 40 | + '/opt/lib', |
| 41 | + '/opt/local/lib', |
| 42 | + '/opt/homebrew/lib', |
| 43 | + '/opt/homebrew/opt/ta-lib/lib', |
| 44 | + ] |
| 45 | + |
| 46 | +elif sys.platform == "win32": |
57 | 47 | platform_supported = True
|
58 | 48 | lib_talib_name = 'ta_libc_cdr'
|
59 | 49 | include_dirs = [r"c:\ta-lib\c\include"]
|
60 |
| - lib_talib_dirs = [r"c:\ta-lib\c\lib"] |
| 50 | + library_dirs = [r"c:\ta-lib\c\lib"] |
| 51 | + |
| 52 | +if 'TA_INCLUDE_PATH' in os.environ: |
| 53 | + paths = os.environ['TA_INCLUDE_PATH'].split(os.pathsep) |
| 54 | + include_dirs.extend(path for path in paths if path) |
| 55 | + |
| 56 | +if 'TA_LIBRARY_PATH' in os.environ: |
| 57 | + paths = os.environ['TA_LIBRARY_PATH'].split(os.pathsep) |
| 58 | + library_dirs.extend(path for path in paths if path) |
61 | 59 |
|
62 | 60 | if not platform_supported:
|
63 | 61 | raise NotImplementedError(sys.platform)
|
|
68 | 66 | except ImportError:
|
69 | 67 | has_cython = False
|
70 | 68 |
|
71 |
| -for lib_talib_dir in lib_talib_dirs: |
| 69 | +for path in library_dirs: |
72 | 70 | try:
|
73 |
| - files = os.listdir(lib_talib_dir) |
| 71 | + files = os.listdir(path) |
74 | 72 | if any(lib_talib_name in f for f in files):
|
75 | 73 | break
|
76 | 74 | except OSError:
|
@@ -135,9 +133,9 @@ def build_extensions(self):
|
135 | 133 | 'talib._ta_lib',
|
136 | 134 | ['talib/_ta_lib.pyx' if has_cython else 'talib/_ta_lib.c'],
|
137 | 135 | include_dirs=include_dirs,
|
138 |
| - library_dirs=lib_talib_dirs, |
| 136 | + library_dirs=library_dirs, |
139 | 137 | libraries=[lib_talib_name],
|
140 |
| - runtime_library_dirs=runtime_lib_dirs) |
| 138 | + runtime_library_dirs=library_dirs) |
141 | 139 | ]
|
142 | 140 |
|
143 | 141 | from os import path
|
|
0 commit comments