Skip to content

Commit f1e4a50

Browse files
committed
Support PEP-517 style installation
1 parent 3bebd6d commit f1e4a50

File tree

6 files changed

+83
-113
lines changed

6 files changed

+83
-113
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.6.5
2+
=====
3+
4+
- [FIX]: Support PEP-517 style installation
5+
16
0.6.4
27
=====
38

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.PHONY: build
22

33
build:
4-
python3 setup.py build_ext --inplace
4+
python3 -m pip install --use-pep517 -e .
55

66
install:
7-
python3 setup.py install
7+
python3 -m pip install --use-pep517 .
88

99
talib/_func.pxi: tools/generate_func.py
1010
python3 tools/generate_func.py > talib/_func.pxi
@@ -15,7 +15,7 @@ talib/_stream.pxi: tools/generate_stream.py
1515
generate: talib/_func.pxi talib/_stream.pxi
1616

1717
cython:
18-
cython --directive emit_code_comments=False talib/_ta_lib.pyx
18+
cython talib/_ta_lib.pyx
1919

2020
clean:
2121
rm -rf build talib/_ta_lib.so talib/*.pyc
@@ -24,7 +24,7 @@ perf:
2424
python3 tools/perf_talib.py
2525

2626
test: build
27-
LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} pytest
27+
pytest tests/
2828

2929
sdist:
30-
python3 setup.py sdist --formats=gztar,zip
30+
python3 -m build --sdist

pyproject.toml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,52 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "Cython", "numpy"]
3+
build-backend = "setuptools.build_meta"
4+
15
[project]
2-
name = "ta-lib"
3-
version = "0.6.4"
4-
dynamic = ["authors", "classifiers", "description", "license", "readme"]
6+
name = "TA-Lib"
7+
version = "0.6.5"
8+
description = "Python wrapper for TA-Lib"
9+
readme = "README.md"
10+
license = "BSD-2-Clause"
11+
authors = [
12+
{name = "John Benediktsson", email = "[email protected]"}
13+
]
14+
urls = {homepage = "http://github.com/ta-lib/ta-lib-python", download = "https://github.com/ta-lib/ta-lib-python/releases"}
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Operating System :: Unix",
18+
"Operating System :: POSIX",
19+
"Operating System :: MacOS :: MacOS X",
20+
"Operating System :: Microsoft :: Windows",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 2",
23+
"Programming Language :: Python :: 2.7",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: 3.3",
26+
"Programming Language :: Python :: 3.4",
27+
"Programming Language :: Python :: 3.5",
28+
"Programming Language :: Python :: 3.6",
29+
"Programming Language :: Python :: 3.7",
30+
"Programming Language :: Python :: 3.8",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
33+
"Programming Language :: Python :: 3.11",
34+
"Programming Language :: Python :: 3.12",
35+
"Programming Language :: Python :: 3.13",
36+
"Programming Language :: Python :: 3.14",
37+
"Programming Language :: Cython",
38+
"Topic :: Office/Business :: Financial",
39+
"Topic :: Scientific/Engineering :: Mathematics",
40+
"Intended Audience :: Developers",
41+
"Intended Audience :: Science/Research",
42+
"Intended Audience :: Financial and Insurance Industry",
43+
]
544
dependencies = [
6-
"setuptools",
45+
"build",
746
"numpy",
47+
"pip",
848
]
49+
50+
[tool.setuptools]
51+
packages = ["talib"]
52+
package-data = {"talib" = ["_ta_lib.pyi", "py.typed"]}

requirements_dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
beautifulsoup4
33
mistune
44
Pygments
5+
build
6+
cython

setup.py

Lines changed: 22 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@
55
import os.path
66
import 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

2111
platform_supported = False
2212

@@ -83,55 +73,30 @@
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

136101
ext_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-
151111
setup(
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-
author_email='[email protected]',
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+
)

talib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def wrapper(*args, **kwds):
132132
setattr(stream, func_name, wrapped_func)
133133
globals()[stream_func_name] = wrapped_func
134134

135-
__version__ = '0.6.4'
135+
__version__ = '0.6.5'
136136

137137
# In order to use this python library, talib (i.e. this __file__) will be
138138
# imported at some point, either explicitly or indirectly via talib.func

0 commit comments

Comments
 (0)