Release #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
linux: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# Ubuntu 22.04 (libc 2.35) | |
- os: ubuntu-22.04 | |
target: x86_64 | |
manylinux: manylinux_2_35 | |
python-versions: '["3.11", "3.12"]' | |
# Ubuntu 24.04 (libc 2.38) | |
- os: ubuntu-24.04 | |
target: x86_64 | |
manylinux: manylinux_2_38 | |
python-versions: '["3.11", "3.12"]' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Cache static OpenCV | |
id: cache-opencv | |
uses: actions/cache@v4 | |
with: | |
path: third_party/opencv-static | |
key: opencv-static-4.12.0-no-itt-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }} | |
- name: Install build dependencies | |
run: | | |
# Disable all interactive prompts system-wide | |
sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get update | |
# Install basic LLVM for opencv-rust bindings codegen | |
sudo apt-get install -y clang libclang-dev llvm-dev cmake curl wget software-properties-common | |
# For Ubuntu 22.04, use the default LLVM 14 instead of PPA to avoid restart issues | |
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then | |
echo "Using default LLVM 14 for Ubuntu 22.04 to avoid restart issues" | |
sudo apt-get install -y llvm-14 llvm-14-dev llvm-14-tools libclang-14-dev | |
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-14" >> $GITHUB_ENV | |
else | |
# Ubuntu 24.04 has LLVM 18 by default | |
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18 | |
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV | |
fi | |
# Find the correct libclang.so path and set environment variables | |
LIBCLANG_PATH=$(find /usr -name "libclang.so" 2>/dev/null | head -1 | xargs dirname) | |
echo "LIBCLANG_PATH=$LIBCLANG_PATH" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$LIBCLANG_PATH:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
# Verify the key files exist | |
echo "Found libclang.so at:" | |
find /usr -name "libclang.so" 2>/dev/null | |
echo "LLVM config at: $(which llvm-config-14 2>/dev/null || which llvm-config-18 2>/dev/null)" | |
- name: Build static OpenCV | |
if: steps.cache-opencv.outputs.cache-hit != 'true' | |
run: | | |
./scripts/build-opencv-static.sh | |
- name: Build wheels for multiple Python versions | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist --no-default-features --features python-bindings,simd,opencv | |
sccache: 'false' | |
container: off | |
manylinux: ${{ matrix.manylinux }} | |
env: | |
# Use stable ABI for forward compatibility | |
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1' | |
# LLVM for opencv-rust bindings (from earlier install step) | |
LIBCLANG_PATH: ${{ env.LIBCLANG_PATH }} | |
LLVM_CONFIG_PATH: /usr/bin/llvm-config-18 | |
# OpenCV static linking configuration | |
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=stdc++ | |
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.os }}-${{ matrix.target }} | |
path: dist | |
macos: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
target: [aarch64] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Cache static OpenCV | |
id: cache-opencv | |
uses: actions/cache@v4 | |
with: | |
path: third_party/opencv-static | |
key: opencv-static-4.12.0-no-itt-macos-${{ runner.os }}-${{ runner.arch }} | |
- name: Install build dependencies | |
run: | | |
# Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore) | |
brew install llvm cmake | |
# 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 | |
- name: Build static OpenCV | |
if: steps.cache-opencv.outputs.cache-hit != 'true' | |
run: | | |
./scripts/build-opencv-static.sh | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv,metal | |
sccache: 'false' | |
env: | |
# Use stable ABI for forward compatibility | |
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1' | |
# OpenCV static linking configuration | |
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,framework=Accelerate,dylib=c++ | |
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-${{ matrix.target }} | |
path: dist | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [linux, macos, sdist] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
merge-multiple: true | |
path: dist | |
- name: List built wheels | |
run: | | |
echo "Built wheels:" | |
ls -la dist/ | |
echo "Wheel information:" | |
python -c "import zipfile; [print(f'{f}: {zipfile.ZipFile(f).namelist()[:3]}') for f in [f for f in __import__('os').listdir('dist') if f.endswith('.whl')]]" | |
- name: Publish to PyPI | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |