Skip to content
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
135 changes: 89 additions & 46 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ jobs:
strategy:
matrix:
target: [x86_64]
#, aarch64-unknown-linux-gnu]
#, aarch64, armv7]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -51,7 +49,7 @@ jobs:
TA_LIBRARY_PATH: ${{ github.workspace }}/dependencies/lib
- name: Test
run: |
uv run pytest
uv run --extra test pytest
env:
DEPS_PATH: ${{ github.workspace }}/dependencies
TA_INCLUDE_PATH: ${{ github.workspace }}/dependencies/include
Expand Down Expand Up @@ -111,52 +109,85 @@ jobs:
TA_INCLUDE_PATH: ${{ github.workspace }}/dependencies/include
TA_LIBRARY_PATH: ${{ github.workspace }}/dependencies/lib
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-linux-${{ matrix.target }}
path: dist
- name: Test wheel installation
run: |
pip install dist/*.whl
python -c "import polars_talib; print('Import successful')"

linux-arm:
runs-on: ubuntu-24.04-arm
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64]
# armv7l]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: install uv
uses: astral-sh/setup-uv@v5
- name: install tools
run: |
uv tool install maturin
- name: Install talib
run: |
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib-0.6.4-src.tar.gz
tar -xzf ta-lib-0.6.4-src.tar.gz
cd ta-lib-0.6.4
./configure
make
sudo make install
cd ..
rm -rf ta-lib-0.6.4
env:
TA_INCLUDE_PATH: ${{ github.workspace }}/dependencies/include
TA_LIBRARY_PATH: ${{ github.workspace }}/dependencies/lib
- name: Build wheels
run: |
maturin build --release --out dist --find-interpreter
env:
DEPS_PATH: ${{ github.workspace }}/dependencies
TA_INCLUDE_PATH: ${{ github.workspace }}/dependencies/include
TA_LIBRARY_PATH: ${{ github.workspace }}/dependencies/lib
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: uraimo/run-on-arch-action@v3
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt update
apt install -y libclang-dev build-essential curl wget pkg-config
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc
export PATH="$HOME/.local/bin:$PATH"
uv python install 3.10
uv tool install maturin
# Download and build ta-lib
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib-0.6.4-src.tar.gz
tar -xzf ta-lib-0.6.4-src.tar.gz
cd ta-lib-0.6.4
./configure --prefix=/usr/local
make
make install
ldconfig
cd ..
rm -rf ta-lib-0.6.4
run: |
export DEPS_PATH=$PWD/dependencies
export TA_INCLUDE_PATH=$PWD/dependencies/include
export TA_LIBRARY_PATH=$PWD/dependencies/lib
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
export LIBRARY_PATH=/usr/local/lib:/usr/lib
source $HOME/.cargo/env
export PATH="$HOME/.local/bin:$PATH"
# Check if ta-lib is installed system-wide
if pkg-config --exists talib 2>/dev/null; then
echo "Using system ta-lib"
export TA_INCLUDE_PATH=$(pkg-config --cflags-only-I talib | sed 's/-I//g')
export TA_LIBRARY_PATH=$(pkg-config --libs-only-L talib | sed 's/-L//g')
fi
uv run maturin build --release --out dist --find-interpreter
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-linux-arm-${{ matrix.target }}
path: dist
- name: Test wheel installation
uses: uraimo/run-on-arch-action@v3
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt update
apt install -y python3 python3-pip
run: |
pip3 install dist/*.whl
python3 -c "import polars_talib; print('Import successful')"


windows:
Expand All @@ -165,7 +196,7 @@ jobs:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand Down Expand Up @@ -194,18 +225,24 @@ jobs:
TA_INCLUDE_PATH: ${{ github.workspace }}\dependencies\include
TA_LIBRARY_PATH: ${{ github.workspace }}\dependencies\lib
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-windows-${{ matrix.target }}
path: dist
- name: Test wheel installation (x64 only)
if: matrix.target == 'x64'
run: |
pip install dist/*.whl
python -c "import polars_talib; print('Import successful')"
shell: bash

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64-apple-darwin]
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -225,20 +262,26 @@ jobs:
TA_INCLUDE_PATH: ${{ github.workspace }}/dependencies/include
TA_LIBRARY_PATH: ${{ github.workspace }}/dependencies/lib
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-macos-${{ matrix.target }}
path: dist
- name: Test wheel installation (aarch64 only)
if: matrix.target == 'aarch64'
run: |
pip install dist/*.whl
python -c "import polars_talib; print('Import successful')"

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, macos, windows]
if: startsWith(github.ref, 'refs/tags/')
needs: [linux, macos, windows, linux-arm]
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: wheels
pattern: wheels-*
merge-multiple: true
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,6 @@ dmypy.json
cython_debug/

# pytest benchmark
.benchmarks
.benchmarks

.DS_Store
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ dev = [
"hypothesis",
"pytest-memray==1.4.0; python_version >= '3.8'",
"pytest-benchmark",
]


[project.optional-dependencies]
test = [
"pytest>=7.4.4",
"ta-lib==0.5.3",
]

Expand Down
2 changes: 0 additions & 2 deletions talib-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ flate2 = "1.0.26"
zip-extract = "0.1.2"
fs_extra = "1.3.0"

[build]
rustc-cdylib-link-arg = "--no-size_t-is-usize"
31 changes: 28 additions & 3 deletions talib-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// const TA_LIB_TGZ: &str = "ta-lib-0.4.0-src.tar.gz";

#[derive(Debug)]
struct DerivesCallback;

Check warning on line 13 in talib-sys/build.rs

View workflow job for this annotation

GitHub Actions / linux-arm (aarch64)

struct `DerivesCallback` is never constructed

impl ParseCallbacks for DerivesCallback {
// Test the "custom derives" capability by adding `PartialEq` to the `Test` struct.
Expand Down Expand Up @@ -170,9 +170,34 @@
}
}

println!("cargo:rustc-link-lib=static=ta_lib");
println!("cargo:rustc-link-search=native={ta_library_path}");
println!("cargo:rustc-link-search=native=../dependencies/lib");
// Try to use pkg-config first for system-installed ta-lib
let os = std::env::consts::OS;
if os != "windows" && Command::new("pkg-config")
.args(&["--exists", "talib"])
.output()
.map(|output| output.status.success())
.unwrap_or(false)
{
println!("cargo:rustc-link-lib=ta_lib");
if let Ok(output) = Command::new("pkg-config")
.args(&["--libs-only-L", "talib"])
.output()
{
let lib_dirs = String::from_utf8_lossy(&output.stdout);
for lib_dir in lib_dirs.split_whitespace() {
if let Some(path) = lib_dir.strip_prefix("-L") {
println!("cargo:rustc-link-search=native={}", path);
}
}
}
// Add standard system paths as fallback
println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-search=native=/usr/lib");
} else {
println!("cargo:rustc-link-lib=static=ta_lib");
println!("cargo:rustc-link-search=native={ta_library_path}");
println!("cargo:rustc-link-search=native=../dependencies/lib");
}
// let cb = ParseCallbacks::add_derives();
let bindings = bindgen::Builder::default()
// The input header we would like to generate
Expand Down
Loading
Loading