Skip to content
Merged
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
69 changes: 37 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18

# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.12 from source..."
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.11 from source..."
cd /tmp
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
tar -xzf 4.12.0.tar.gz
cd opencv-4.12.0
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
tar -xzf 4.11.0.tar.gz
cd opencv-4.11.0
mkdir build
cd build
cmake \
Expand Down Expand Up @@ -127,12 +127,12 @@ jobs:
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18

# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.12 from source..."
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.11 from source..."
cd /tmp
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
tar -xzf 4.12.0.tar.gz
cd opencv-4.12.0
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
tar -xzf 4.11.0.tar.gz
cd opencv-4.11.0
mkdir build
cd build
cmake \
Expand Down Expand Up @@ -218,12 +218,12 @@ jobs:
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18

# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.12 from source..."
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.11 from source..."
cd /tmp
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
tar -xzf 4.12.0.tar.gz
cd opencv-4.12.0
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
tar -xzf 4.11.0.tar.gz
cd opencv-4.11.0
mkdir build
cd build
cmake \
Expand Down Expand Up @@ -298,12 +298,12 @@ jobs:
ls -la /usr/lib/llvm-18/lib/libclang.so
which llvm-config-18

# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.12 from source..."
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
echo "Building OpenCV 4.11 from source..."
cd /tmp
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
tar -xzf 4.12.0.tar.gz
cd opencv-4.12.0
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
tar -xzf 4.11.0.tar.gz
cd opencv-4.11.0
mkdir build
cd build
cmake \
Expand Down Expand Up @@ -348,19 +348,19 @@ jobs:
- name: Install maturin (Linux/macOS)
run: pip install maturin[patchelf]

- name: Install OpenCV (macOS)
- name: Install OpenCV build dependencies (macOS)
if: runner.os == 'macOS'
run: |
# Install OpenCV and LLVM via Homebrew
brew install opencv llvm
# Build against a pinned OpenCV version instead of Homebrew's moving target
brew install llvm cmake nasm pkg-config
# 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 static OpenCV (macOS)
if: runner.os == 'macOS'
run: ./scripts/build-opencv-static.sh

- name: Build wheels (Linux)
if: runner.os == 'Linux'
Expand All @@ -369,6 +369,11 @@ jobs:
- name: Build wheels (macOS)
if: runner.os == 'macOS'
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv,metal
env:
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
OPENCV_LINK_LIBS: static=opencv_world,static=avformat,static=avcodec,static=avfilter,static=swresample,static=swscale,static=avutil,static=jpeg,static=png,static=tiff,static=webp,static=jasper,framework=Accelerate,dylib=c++,framework=OpenCL,z
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake


- name: Upload wheels
Expand Down Expand Up @@ -398,12 +403,12 @@ jobs:
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

# Build OpenCV 4.12 from source
echo "Building OpenCV 4.12 from source..."
# Build OpenCV 4.11 from source
echo "Building OpenCV 4.11 from source..."
cd /tmp
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
tar -xzf 4.12.0.tar.gz
cd opencv-4.12.0
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
tar -xzf 4.11.0.tar.gz
cd opencv-4.11.0
mkdir build
cd build
cmake \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/cache@v4
with:
path: third_party/opencv-static
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}

- name: Install build dependencies
run: |
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
uses: actions/cache@v4
with:
path: third_party/opencv-static
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-aarch64-${{ runner.arch }}-manylinux_2_39
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-aarch64-${{ runner.arch }}-manylinux_2_39

- name: Install build dependencies
run: |
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
uses: actions/cache@v4
with:
path: third_party/opencv-static
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-macos-${{ runner.os }}-${{ runner.arch }}
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-macos-${{ runner.os }}-${{ runner.arch }}

- name: Install build dependencies
run: |
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ num_cpus = "1.16"
numpy = {version = "0.22", optional = true}
objc = {version = "0.2", optional = true}
# OpenCV bindings for performance parity
opencv = {version = "0.93", optional = true}
# Limit binding generation to the modules this crate actually uses.
opencv = {version = "0.98", optional = true, default-features = false, features = ["clang-runtime", "imgproc", "videoio"]}
# Python bindings (optional)
pyo3 = {version = "0.22", features = ["extension-module"], optional = true}
rayon = "1.8"
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[toolchain]
channel = "1.89"
components = ["rustfmt", "clippy"]
profile = "minimal"
2 changes: 1 addition & 1 deletion scripts/build-opencv-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
# Build static OpenCV bundle for embedding in Python wheels
# This eliminates the need for users to install OpenCV system packages

OPENCV_VERSION="4.12.0"
OPENCV_VERSION="4.11.0"
FFMPEG_VERSION="6.1.1"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
Expand Down
Loading
Loading