Skip to content

fix static build

fix static build #87

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
rust-tests:
name: Rust Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OpenCV and LLVM dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
# Install LLVM 18 which has the proper libclang.so symlink
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
# Set environment variables for LLVM 18
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# Verify the key files exist
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --no-default-features --features python-bindings,simd,opencv -- -D warnings
- name: Run tests (no Python bindings)
run: cargo test --no-default-features --features simd,opencv
- name: Compile tests (Linux compatible features)
run: cargo test --no-default-features --features python-bindings,simd,opencv --no-run
python-tests:
name: Python Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install OpenCV and LLVM dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
# Install LLVM 18 which has the proper libclang.so symlink
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
# Set environment variables for LLVM 18
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# Verify the key files exist
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85
- name: Install maturin (Linux/macOS)
run: pip install maturin[patchelf]
- name: Build Python package (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p dist
maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv
- name: Build Python package (macOS)
if: runner.os == 'macOS'
run: |
mkdir -p dist
maturin build --release --out dist --no-default-features --features python-bindings,simd,metal
- name: Install built package (Linux/macOS)
run: pip install dist/*.whl
- name: Install test dependencies
run: pip install pytest pytest-benchmark numpy pillow opencv-python
- name: Run Python tests
run: pytest tests/ -v
pre-commit:
name: Pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OpenCV and LLVM dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
# Install LLVM 18 which has the proper libclang.so symlink
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
# Set environment variables for LLVM 18
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# Verify the key files exist
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
build-wheels:
name: Build wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install OpenCV and LLVM dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
# Install LLVM 18 which has the proper libclang.so symlink
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
# Set environment variables for LLVM 18
echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# Verify the key files exist
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85
- name: Install maturin (Linux/macOS)
run: pip install maturin[patchelf]
- name: Install OpenCV (macOS)
if: runner.os == 'macOS'
run: |
# Install OpenCV and LLVM via Homebrew
brew install opencv llvm
# Set up LLVM environment for opencv-rust bindings (keg-only installation)
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
# Set up OpenCV environment
echo "OPENCV_LINK_LIBS=opencv_calib3d,opencv_core,opencv_dnn,opencv_features2d,opencv_flann,opencv_highgui,opencv_imgcodecs,opencv_imgproc,opencv_ml,opencv_objdetect,opencv_photo,opencv_stitching,opencv_video,opencv_videoio" >> $GITHUB_ENV
echo "OPENCV_LINK_PATHS=/opt/homebrew/lib" >> $GITHUB_ENV
echo "OPENCV_INCLUDE_PATHS=/opt/homebrew/include/opencv4" >> $GITHUB_ENV
- name: Build wheels (Linux)
if: runner.os == 'Linux'
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv
- name: Build wheels (macOS)
if: runner.os == 'macOS'
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv,metal
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist/