Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflow for automated Python wheel builds across multiple platforms #699

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 304 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@

name: TA-Lib-python GitHub Actions to build wheels
run-name: TA-Lib-python GitHub Actions to build wheels
on:
push:
tags:
- "v*"

env:
TALIB_C_VER: 0.6.2
TALIB_PY_VER: ${{ github.ref_name }}

jobs:
build_manylinux_x86_64:
name: Build ManyLinux x86_64 wheels
strategy:
matrix:
os: ["ubuntu-22.04"]
runs-on: ${{ matrix.os }}
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_I686_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_I686_IMAGE: manylinux_2_28
CIBW_BEFORE_BUILD: pip install setuptools==58.0.1&&pip install -U Cython&&pip install -U wheel numpy
CIBW_BEFORE_TEST: pip install -U Cython
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32 cp*"
CIBW_SKIP: "pp* cp*-musllinux*"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install GCC and CMake
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake
- name: Make script executable
run: chmod +x ./tools/build_wheel_linux.sh
- name: Build TA-Lib
run: ./tools/build_wheel_linux.sh
shell: bash
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BUILD_FRONTEND: build
CIBW_ENVIRONMENT_LINUX : >
TA_LIBRARY_PATH="ta-lib-install/lib"
TA_INCLUDE_PATH="ta-lib-install/include"
PIP_NO_BUILD_ISOLATION=false
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
export LD_LIBRARY_PATH="/project/ta-lib-install/lib:$LD_LIBRARY_PATH"
auditwheel repair -w {dest_dir} {wheel}
- name: Set wheel name
run: |
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-manylinux_x86_64" >> $GITHUB_ENV
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
build_musllinux_x86_64:
name: Build MuslLinux x86_64 wheels
strategy:
matrix:
os: ["ubuntu-22.04"]
runs-on: ${{ matrix.os }}
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
CIBW_BEFORE_BUILD: pip install setuptools==58.0.1&&pip install Cython==0.29.37&&pip install -U wheel numpy
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
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32 cp*"
CIBW_SKIP: "pp* cp*-manylinux*"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup latest Alpine Linux
uses: jirutka/setup-alpine@v1
with:
branch: v3.15
packages: >
build-base
bash
curl
unzip
gcc
g++
cmake
volumes: ${{ github.workspace }}:/project
- name: Make script executable
run: chmod +x ./tools/build_wheel_linux.sh
- name: Build TA-Lib
run: |
./tools/build_wheel_linux.sh
shell: alpine.sh {0}
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BUILD_FRONTEND: build
CIBW_ENVIRONMENT_LINUX : >
TA_LIBRARY_PATH="ta-lib-install/lib"
TA_INCLUDE_PATH="ta-lib-install/include"
PIP_NO_BUILD_ISOLATION=false
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
export LD_LIBRARY_PATH="/project/ta-lib-install/lib:$LD_LIBRARY_PATH"
auditwheel repair -w {dest_dir} {wheel}
- name: Set wheel name
run: |
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-musllinux_x86_64" >> $GITHUB_ENV
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
build_windows_amd64:
name: Build Windows amd64 wheels
strategy:
matrix:
os: ["windows-2022"]
runs-on: ${{ matrix.os }}
env:
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up MSVC for x64
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Build TA-Lib C library
run: tools/build_wheel_windows.cmd
shell: cmd
- name: Build wheels
uses: pypa/[email protected]
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
CIBW_BEFORE_BUILD: pip install -U setuptools wheel numpy Cython
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest --rootdir=C: -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32*"
CIBW_SKIP: "pp*"
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ENVIRONMENT_WINDOWS: >
TA_LIBRARY_PATH="ta-lib-$TALIB_C_VER\\_build;$LIB"
TA_INCLUDE_PATH="ta-lib-$TALIB_C_VER\\include;$INCLUDE"
PIP_NO_BUILD_ISOLATION=false
- name: Set wheel name
run: |
echo ("WHEEL_NAME=" + "ta_lib-" + $env:TALIB_PY_VER + "-win_amd64") >> $env:GITHUB_ENV
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
build_windows_x86:
name: Build Windows x86 wheels
strategy:
matrix:
os: ["windows-2022"]
runs-on: ${{ matrix.os }}
env:
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up MSVC for x86
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_x86
- name: Build TA-Lib C library
run: tools/build_wheel_windows.cmd
shell: cmd
- name: Build wheels
uses: pypa/[email protected]
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
CIBW_BEFORE_BUILD: pip install -U setuptools wheel numpy Cython
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest --rootdir=C: -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32 cp*"
CIBW_SKIP: "pp*"
MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT: 1
CIBW_ARCHS_WINDOWS: x86
CIBW_ENVIRONMENT_WINDOWS: >
TA_LIBRARY_PATH="ta-lib-$TALIB_C_VER\\_build;$LIB"
TA_INCLUDE_PATH="ta-lib-$TALIB_C_VER\\include;$INCLUDE"
PIP_NO_BUILD_ISOLATION=false
- name: Set wheel name
run: |
echo ("WHEEL_NAME=" + "ta_lib-" + $env:TALIB_PY_VER + "-win32") >> $env:GITHUB_ENV
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
build_macos_x86_64:
name: Build MacOS x86_64 wheels
strategy:
matrix:
os: [macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make script executable
run: chmod +x ./tools/build_wheel_macos.sh
- name: Build TA-Lib
run: ./tools/build_wheel_macos.sh
shell: bash
- name: Build wheels
uses: pypa/[email protected]
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
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
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32 cp*"
CIBW_SKIP: "pp*"
CIBW_ARCHS_MACOS: x86_64
CIBW_ENVIRONMENT_MACOS : >
TA_LIBRARY_PATH="ta-lib-install/lib"
TA_INCLUDE_PATH="ta-lib-install/include"
PIP_NO_BUILD_ISOLATION=false
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
export MACOSX_DEPLOYMENT_TARGET=13.7
export DYLD_LIBRARY_PATH="/Users/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/ta-lib-install/lib:$DYLD_LIBRARY_PATH"
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
- name: Set wheel name
run: |
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-macos_x86_64" >> $GITHUB_ENV
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
build_macos_arm64:
name: Build MacOS arm64 wheels
strategy:
matrix:
os: [macos-14]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make script executable
run: chmod +x ./tools/build_wheel_macos.sh
- name: Build TA-Lib
run: ./tools/build_wheel_macos.sh
shell: bash
- name: Build wheels
uses: pypa/[email protected]
env:
PIP_NO_VERIFY: 0
PIP_VERBOSE: 1
CIBW_BUILD_VERBOSITY: 2
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
CIBW_TEST_REQUIRES: pytest pandas polars
CIBW_TEST_COMMAND: >
cd .. &&
pytest -k "not RSI and not threading" {project}/tests
CIBW_TEST_SKIP: "*win32 cp*"
CIBW_SKIP: "pp*"
CIBW_ARCHS_MACOS: arm64
CIBW_ENVIRONMENT_MACOS : >
TA_LIBRARY_PATH="ta-lib-install/lib"
TA_INCLUDE_PATH="ta-lib-install/include"
PIP_NO_BUILD_ISOLATION=false
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
export MACOSX_DEPLOYMENT_TARGET=14.0
export DYLD_LIBRARY_PATH="/Users/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/ta-lib-install/lib:$DYLD_LIBRARY_PATH"
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
- name: Set wheel name
run: |
echo "WHEEL_NAME=ta_lib-${{env.TALIB_PY_VER}}-macosx_arm64" >> $GITHUB_ENV
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ env.WHEEL_NAME }}
54 changes: 54 additions & 0 deletions tools/build_wheel_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# TALIB_C_VER=0.6.2
# TALIB_PY_VER=0.5.2
CMAKE_GENERATOR="Unix Makefiles"
CMAKE_BUILD_TYPE=Release
CMAKE_CONFIGURATION_TYPES=Release

# Download TA-Lib C Library
curl -L -o talib-c.zip https://github.com/TA-Lib/ta-lib/archive/refs/tags/v${TALIB_C_VER}.zip
if [ $? -ne 0 ]; then
echo "Failed to download TA-Lib C library"
exit 1
fi

# Unzip TA-Lib C
unzip -q talib-c.zip
if [ $? -ne 0 ]; then
echo "Failed to extract TA-Lib C library"
exit 1
fi

# cd to TA-Lib C
cd ta-lib-${TALIB_C_VER}

# Copy TA-Lib C headers to TA-Lib Python
mkdir -p include/ta-lib/
cp include/*.h include/ta-lib/

# Create build directory
mkdir -p _build
cd _build

# Use CMake to configure the build
cmake -G "$CMAKE_GENERATOR" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=../../ta-lib-install ..
if [ $? -ne 0 ]; then
echo "CMake configuration failed"
exit 1
fi

# Compile TA-Lib
make
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi

make install
if [ $? -ne 0 ]; then
echo "Install failed"
exit 1
fi

echo "TA-Lib build completed successfully!"
Loading