forked from TA-Lib/ta-lib-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
123 lines (108 loc) · 3.6 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
import sys
import os
import warnings
from distutils.dist import Distribution
display_option_names = Distribution.display_option_names + ['help', 'help-commands']
query_only = any('--' + opt in sys.argv for opt in display_option_names) or len(sys.argv) < 2 or sys.argv[1] == 'egg_info'
# Use setuptools for querying the package, normal builds use distutils
if query_only:
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
else:
from distutils.core import setup
from distutils.extension import Extension
lib_talib_name = 'ta_lib' # the underlying C library's name
platform_supported = False
for prefix in ['darwin', 'linux', 'bsd']:
if prefix in sys.platform:
platform_supported = True
include_dirs = [
'/usr/include',
'/usr/local/include',
'/opt/include',
'/opt/local/include',
]
if 'TA_INCLUDE_PATH' in os.environ:
include_dirs.append(os.environ['TA_INCLUDE_PATH'])
lib_talib_dirs = [
'/usr/lib',
'/usr/local/lib',
'/usr/lib64',
'/usr/local/lib64',
'/opt/lib',
'/opt/local/lib',
]
if 'TA_LIBRARY_PATH' in os.environ:
lib_talib_dirs.append(os.environ['TA_LIBRARY_PATH'])
break
if sys.platform == "win32":
platform_supported = True
lib_talib_name = 'ta_libc_cdr'
include_dirs = [r"c:\ta-lib\c\include"]
lib_talib_dirs = [r"c:\ta-lib\c\lib"]
# Do not require numpy or cython for just querying the package
if not query_only:
import numpy
include_dirs.insert(0, numpy.get_include())
try:
from Cython.Distutils import build_ext
has_cython = True
except ImportError:
has_cython = False
if not platform_supported:
raise NotImplementedError(sys.platform)
for lib_talib_dir in lib_talib_dirs:
try:
files = os.listdir(lib_talib_dir)
if any(lib_talib_name in f for f in files):
break
except OSError:
pass
else:
warnings.warn('Cannot find ta-lib library, installation may fail.')
cmdclass = {}
if has_cython:
cmdclass['build_ext'] = build_ext
ext_modules = []
for name in ['common', 'func', 'abstract']:
ext = Extension(
'talib.%s' % name,
[('talib/%s.pyx' if has_cython else 'talib/%s.c') % name],
include_dirs = include_dirs,
library_dirs = lib_talib_dirs,
libraries = [lib_talib_name]
)
ext_modules.append(ext)
setup(
name = 'TA-Lib',
version = '0.4.9',
description = 'Python wrapper for TA-Lib',
author = 'John Benediktsson',
author_email = '[email protected]',
url = 'http://github.com/mrjbq7/ta-lib',
download_url = 'https://github.com/mrjbq7/ta-lib/releases',
classifiers = [
"License :: OSI Approved :: BSD License",
"Development Status :: 4 - Beta",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Cython",
"Topic :: Office/Business :: Financial",
"Topic :: Scientific/Engineering :: Mathematics",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Financial and Insurance Industry",
],
packages = ['talib'],
ext_modules = ext_modules,
cmdclass = cmdclass,
requires = ['numpy'],
)