Skip to content

Commit 1df1861

Browse files
jstzwjmrjbq7
authored andcommitted
add wheels build scripts
1 parent 7e69b81 commit 1df1861

File tree

4 files changed

+491
-0
lines changed

4 files changed

+491
-0
lines changed

.github/workflows/build.yml

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
2+
name: TA-Lib-python GitHub Actions to build wheels
3+
run-name: TA-Lib-python GitHub Actions to build wheels
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
env:
10+
TALIB_C_VER: ${{ github.ref_name }}
11+
TALIB_PY_VER: 0.6.0
12+
13+
jobs:
14+
build_manylinux_x86_64:
15+
name: Build ManyLinux x86_64 wheels
16+
strategy:
17+
matrix:
18+
os: ["ubuntu-22.04"]
19+
runs-on: ${{ matrix.os }}
20+
env:
21+
PIP_NO_VERIFY: 0
22+
PIP_VERBOSE: 1
23+
CIBW_BUILD_VERBOSITY: 2
24+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
25+
CIBW_MANYLINUX_I686_IMAGE: manylinux_2_28
26+
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux_2_28
27+
CIBW_MANYLINUX_PYPY_I686_IMAGE: manylinux_2_28
28+
CIBW_BEFORE_BUILD: pip install setuptools==58.0.1&&pip install -U Cython&&pip install -U wheel numpy
29+
CIBW_BEFORE_TEST: pip install -U Cython
30+
CIBW_TEST_REQUIRES: pytest pandas polars
31+
CIBW_TEST_COMMAND: >
32+
cd .. &&
33+
pytest -k "not RSI and not threading" {project}/tests
34+
CIBW_TEST_SKIP: "*win32 cp*"
35+
CIBW_SKIP: "pp* cp*-musllinux*"
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
- name: Install GCC and CMake
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y gcc g++ cmake
43+
- name: Make script executable
44+
run: chmod +x build_linux.sh
45+
- name: Build TA-Lib
46+
run: ./tools/build_wheel_linux.sh
47+
shell: bash
48+
- name: Build wheels
49+
uses: pypa/[email protected]
50+
env:
51+
CIBW_ARCHS_LINUX: x86_64
52+
CIBW_BUILD_FRONTEND: build
53+
CIBW_ENVIRONMENT_LINUX : >
54+
TA_LIBRARY_PATH="ta-lib-install/lib"
55+
TA_INCLUDE_PATH="ta-lib-install/include"
56+
PIP_NO_BUILD_ISOLATION=false
57+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
58+
export LD_LIBRARY_PATH="/project/ta-lib-install/lib:$LD_LIBRARY_PATH"
59+
auditwheel repair -w {dest_dir} {wheel}
60+
- name: Set wheel name
61+
run: |
62+
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-manylinux_x86_64" >> $GITHUB_ENV
63+
- name: Upload wheels
64+
uses: actions/upload-artifact@v4
65+
with:
66+
path: ./wheelhouse/*.whl
67+
name: ${{ env.WHEEL_NAME }}
68+
build_musllinux_x86_64:
69+
name: Build MuslLinux x86_64 wheels
70+
strategy:
71+
matrix:
72+
os: ["ubuntu-22.04"]
73+
runs-on: ${{ matrix.os }}
74+
env:
75+
PIP_NO_VERIFY: 0
76+
PIP_VERBOSE: 1
77+
CIBW_BUILD_VERBOSITY: 2
78+
CIBW_BEFORE_BUILD: pip install setuptools==58.0.1&&pip install Cython==0.29.37&&pip install -U wheel numpy
79+
CIBW_BEFORE_TEST: apk add bash&&bash setup_rust.sh&&. "$HOME/.cargo/env"&&pip install Cython==0.29.37&&pip install -U maturin&&pip install -U polars
80+
CIBW_TEST_REQUIRES: pytest pandas polars
81+
CIBW_TEST_COMMAND: >
82+
cd .. &&
83+
pytest -k "not RSI and not threading" {project}/tests
84+
CIBW_TEST_SKIP: "*win32 cp*"
85+
CIBW_SKIP: "pp* cp*-manylinux*"
86+
steps:
87+
- name: Checkout repository
88+
uses: actions/checkout@v4
89+
- name: Setup latest Alpine Linux
90+
uses: jirutka/setup-alpine@v1
91+
with:
92+
branch: v3.15
93+
packages: >
94+
build-base
95+
bash
96+
curl
97+
unzip
98+
gcc
99+
g++
100+
cmake
101+
volumes: ${{ github.workspace }}:/project
102+
- name: Make script executable
103+
run: chmod +x build_linux.sh
104+
- name: Build TA-Lib
105+
run: |
106+
./tools/build_wheel_linux.sh
107+
shell: alpine.sh {0}
108+
- name: Build wheels
109+
uses: pypa/[email protected]
110+
env:
111+
CIBW_ARCHS_LINUX: x86_64
112+
CIBW_BUILD_FRONTEND: build
113+
CIBW_ENVIRONMENT_LINUX : >
114+
TA_LIBRARY_PATH="ta-lib-install/lib"
115+
TA_INCLUDE_PATH="ta-lib-install/include"
116+
PIP_NO_BUILD_ISOLATION=false
117+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
118+
export LD_LIBRARY_PATH="/project/ta-lib-install/lib:$LD_LIBRARY_PATH"
119+
auditwheel repair -w {dest_dir} {wheel}
120+
- name: Set wheel name
121+
run: |
122+
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-musllinux_x86_64" >> $GITHUB_ENV
123+
- name: Upload wheels
124+
uses: actions/upload-artifact@v4
125+
with:
126+
path: ./wheelhouse/*.whl
127+
name: ${{ env.WHEEL_NAME }}
128+
build_windows_amd64:
129+
name: Build Windows amd64 wheels
130+
strategy:
131+
matrix:
132+
os: ["windows-2022"]
133+
runs-on: ${{ matrix.os }}
134+
env:
135+
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
136+
steps:
137+
- name: Checkout the repository
138+
uses: actions/checkout@v4
139+
- name: Set up MSVC for x64
140+
uses: ilammy/msvc-dev-cmd@v1
141+
with:
142+
arch: amd64
143+
- name: Build TA-Lib C library
144+
run: tools/build_wheel_windows.cmd
145+
shell: cmd
146+
- name: Build wheels
147+
uses: pypa/[email protected]
148+
env:
149+
PIP_NO_VERIFY: 0
150+
PIP_VERBOSE: 1
151+
CIBW_BUILD_VERBOSITY: 2
152+
CIBW_BEFORE_BUILD: pip install -U setuptools wheel numpy Cython
153+
CIBW_TEST_REQUIRES: pytest pandas polars
154+
CIBW_TEST_COMMAND: >
155+
cd .. &&
156+
pytest --rootdir=C: -k "not RSI and not threading" {project}/tests
157+
CIBW_TEST_SKIP: "*win32*"
158+
CIBW_SKIP: "pp*"
159+
CIBW_ARCHS_WINDOWS: AMD64
160+
CIBW_ENVIRONMENT_WINDOWS: >
161+
TA_LIBRARY_PATH="ta-lib-$TALIB_C_VER\\_build;$LIB"
162+
TA_INCLUDE_PATH="ta-lib-$TALIB_C_VER\\include;$INCLUDE"
163+
PIP_NO_BUILD_ISOLATION=false
164+
- name: Set wheel name
165+
run: |
166+
echo ("WHEEL_NAME=" + "ta_lib-" + $env:TALIB_PY_VER + "-win_amd64") >> $env:GITHUB_ENV
167+
- name: Upload wheel
168+
uses: actions/upload-artifact@v4
169+
with:
170+
path: ./wheelhouse/*.whl
171+
name: ${{ env.WHEEL_NAME }}
172+
build_windows_x86:
173+
name: Build Windows x86 wheels
174+
strategy:
175+
matrix:
176+
os: ["windows-2022"]
177+
runs-on: ${{ matrix.os }}
178+
env:
179+
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
180+
steps:
181+
- name: Checkout the repository
182+
uses: actions/checkout@v4
183+
- name: Set up MSVC for x86
184+
uses: ilammy/msvc-dev-cmd@v1
185+
with:
186+
arch: amd64_x86
187+
- name: Build TA-Lib C library
188+
run: tools/build_wheel_windows.cmd
189+
shell: cmd
190+
- name: Build wheels
191+
uses: pypa/[email protected]
192+
env:
193+
PIP_NO_VERIFY: 0
194+
PIP_VERBOSE: 1
195+
CIBW_BUILD_VERBOSITY: 2
196+
CIBW_BEFORE_BUILD: pip install -U setuptools wheel numpy Cython
197+
CIBW_TEST_REQUIRES: pytest pandas polars
198+
CIBW_TEST_COMMAND: >
199+
cd .. &&
200+
pytest --rootdir=C: -k "not RSI and not threading" {project}/tests
201+
CIBW_TEST_SKIP: "*win32 cp*"
202+
CIBW_SKIP: "pp*"
203+
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
204+
CIBW_ARCHS_WINDOWS: x86
205+
CIBW_ENVIRONMENT_WINDOWS: >
206+
TA_LIBRARY_PATH="ta-lib-$TALIB_C_VER\\_build;$LIB"
207+
TA_INCLUDE_PATH="ta-lib-$TALIB_C_VER\\include;$INCLUDE"
208+
PIP_NO_BUILD_ISOLATION=false
209+
- name: Set wheel name
210+
run: |
211+
echo ("WHEEL_NAME=" + "ta_lib-" + $env:TALIB_PY_VER + "-win32") >> $env:GITHUB_ENV
212+
- name: Upload wheel
213+
uses: actions/upload-artifact@v4
214+
with:
215+
path: ./wheelhouse/*.whl
216+
name: ${{ env.WHEEL_NAME }}
217+
build_macos_x86_64:
218+
name: Build MacOS x86_64 wheels
219+
strategy:
220+
matrix:
221+
os: [macos-13]
222+
runs-on: ${{ matrix.os }}
223+
steps:
224+
- name: Checkout repository
225+
uses: actions/checkout@v4
226+
- name: Make script executable
227+
run: chmod +x build_macos.sh
228+
- name: Build TA-Lib
229+
run: ./tools/build_wheel_macos.sh
230+
shell: bash
231+
- name: Build wheels
232+
uses: pypa/[email protected]
233+
env:
234+
PIP_NO_VERIFY: 0
235+
PIP_VERBOSE: 1
236+
CIBW_BUILD_VERBOSITY: 2
237+
CIBW_BEFORE_BUILD: python -c "import sys; from subprocess import call; call(['pip', 'install', 'setuptools==58.0.1' if sys.version_info <= (3, 11) else '-U', 'setuptools'])"&&pip install -U wheel numpy Cython
238+
CIBW_TEST_REQUIRES: pytest pandas polars
239+
CIBW_TEST_COMMAND: >
240+
cd .. &&
241+
pytest -k "not RSI and not threading" {project}/tests
242+
CIBW_TEST_SKIP: "*win32 cp*"
243+
CIBW_SKIP: "pp*"
244+
CIBW_ARCHS_MACOS: x86_64
245+
CIBW_ENVIRONMENT_MACOS : >
246+
TA_LIBRARY_PATH="ta-lib-install/lib"
247+
TA_INCLUDE_PATH="ta-lib-install/include"
248+
PIP_NO_BUILD_ISOLATION=false
249+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
250+
export MACOSX_DEPLOYMENT_TARGET=13.7
251+
export DYLD_LIBRARY_PATH="/Users/runner/work/talib-prebuilt/talib-prebuilt/ta-lib-install/lib:$DYLD_LIBRARY_PATH"
252+
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
253+
- name: Set wheel name
254+
run: |
255+
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-macos_x86_64" >> $GITHUB_ENV
256+
- name: Upload wheels
257+
uses: actions/upload-artifact@v4
258+
with:
259+
path: ./wheelhouse/*.whl
260+
name: ${{ env.WHEEL_NAME }}
261+
build_macos_arm64:
262+
name: Build MacOS arm64 wheels
263+
strategy:
264+
matrix:
265+
os: [macos-14]
266+
runs-on: ${{ matrix.os }}
267+
steps:
268+
- name: Checkout repository
269+
uses: actions/checkout@v4
270+
- name: Make script executable
271+
run: chmod +x build_macos.sh
272+
- name: Build TA-Lib
273+
run: ./tools/build_wheel_macos.sh
274+
shell: bash
275+
- name: Build wheels
276+
uses: pypa/[email protected]
277+
env:
278+
PIP_NO_VERIFY: 0
279+
PIP_VERBOSE: 1
280+
CIBW_BUILD_VERBOSITY: 2
281+
CIBW_BEFORE_BUILD: python -c "import sys; from subprocess import call; call(['pip', 'install', 'setuptools==58.0.1' if sys.version_info <= (3, 11) else '-U', 'setuptools'])"&&pip install -U wheel numpy Cython
282+
CIBW_TEST_REQUIRES: pytest pandas polars
283+
CIBW_TEST_COMMAND: >
284+
cd .. &&
285+
pytest -k "not RSI and not threading" {project}/tests
286+
CIBW_TEST_SKIP: "*win32 cp*"
287+
CIBW_SKIP: "pp*"
288+
CIBW_ARCHS_MACOS: arm64
289+
CIBW_ENVIRONMENT_MACOS : >
290+
TA_LIBRARY_PATH="ta-lib-install/lib"
291+
TA_INCLUDE_PATH="ta-lib-install/include"
292+
PIP_NO_BUILD_ISOLATION=false
293+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
294+
export MACOSX_DEPLOYMENT_TARGET=14.0
295+
export DYLD_LIBRARY_PATH="/Users/runner/work/talib-prebuilt/talib-prebuilt/ta-lib-install/lib:$DYLD_LIBRARY_PATH"
296+
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
297+
- name: Set wheel name
298+
run: |
299+
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-macosx_arm64" >> $GITHUB_ENV
300+
- name: Upload wheels
301+
uses: actions/upload-artifact@v4
302+
with:
303+
path: ./wheelhouse/*.whl
304+
name: ${{ env.WHEEL_NAME }}

tools/build_wheel_linux.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
# TALIB_C_VER=0.6.2
4+
# TALIB_PY_VER=0.5.2
5+
CMAKE_GENERATOR="Unix Makefiles"
6+
CMAKE_BUILD_TYPE=Release
7+
CMAKE_CONFIGURATION_TYPES=Release
8+
9+
# Download TA-Lib C Library
10+
curl -L -o talib-c.zip https://github.com/TA-Lib/ta-lib/archive/refs/tags/v${TALIB_C_VER}.zip
11+
if [ $? -ne 0 ]; then
12+
echo "Failed to download TA-Lib C library"
13+
exit 1
14+
fi
15+
16+
# Download TA-Lib Python
17+
curl -L -o talib-python.zip https://github.com/TA-Lib/ta-lib-python/archive/refs/tags/TA_Lib-${TALIB_PY_VER}.zip
18+
if [ $? -ne 0 ]; then
19+
echo "Failed to download TA-Lib Python library"
20+
exit 1
21+
fi
22+
23+
# Unzip TA-Lib C
24+
unzip -q talib-c.zip
25+
if [ $? -ne 0 ]; then
26+
echo "Failed to extract TA-Lib C library"
27+
exit 1
28+
fi
29+
30+
# Unzip TA-Lib Python
31+
unzip -q talib-python.zip -d ta-lib-python
32+
if [ $? -ne 0 ]; then
33+
echo "Failed to extract TA-Lib Python library"
34+
exit 1
35+
fi
36+
37+
mv ta-lib-python/ta-lib-python-TA_Lib-${TALIB_PY_VER}/* .
38+
rm -r ta-lib-python
39+
40+
# cd to TA-Lib C
41+
cd ta-lib-${TALIB_C_VER}
42+
43+
# Copy TA-Lib C headers to TA-Lib Python
44+
mkdir -p include/ta-lib/
45+
cp include/*.h include/ta-lib/
46+
47+
# Create build directory
48+
mkdir -p _build
49+
cd _build
50+
51+
# Use CMake to configure the build
52+
cmake -G "$CMAKE_GENERATOR" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=../../ta-lib-install ..
53+
if [ $? -ne 0 ]; then
54+
echo "CMake configuration failed"
55+
exit 1
56+
fi
57+
58+
# Compile TA-Lib
59+
make
60+
if [ $? -ne 0 ]; then
61+
echo "Build failed"
62+
exit 1
63+
fi
64+
65+
make install
66+
if [ $? -ne 0 ]; then
67+
echo "Install failed"
68+
exit 1
69+
fi
70+
71+
echo "TA-Lib build completed successfully!"

0 commit comments

Comments
 (0)