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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
39 changes: 35 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
target: x86_64
manylinux: manylinux_2_35
python: '3.12'
- os: ubuntu-22.04
target: x86_64
manylinux: manylinux_2_35
python: '3.13'
# Ubuntu 24.04 (libc 2.39)
- os: ubuntu-24.04
target: x86_64
Expand All @@ -30,6 +34,10 @@ jobs:
target: x86_64
manylinux: manylinux_2_39
python: '3.12'
- os: ubuntu-24.04
target: x86_64
manylinux: manylinux_2_39
python: '3.13'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down Expand Up @@ -111,7 +119,10 @@ jobs:
env:
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
run: |
./scripts/repair-wheel.sh "${{ github.workspace }}/dist/*.whl"
./scripts/repair-wheel.sh dist/*.whl
- name: Prune unrepaired wheels
run: |
find dist -type f -name '*.linux_*.whl' -print -delete

- name: Upload wheels
uses: actions/upload-artifact@v4
Expand All @@ -125,11 +136,12 @@ jobs:
strategy:
matrix:
target: [aarch64]
python: ['3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: ${{ matrix.python }}

- name: Cache static OpenCV
id: cache-opencv
Expand Down Expand Up @@ -163,7 +175,7 @@ jobs:
# 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=avformat,static=avcodec,static=avfilter,static=swresample,static=swscale,static=avutil,static=jpeg,static=png,static=tiff,static=webp,static=jasper,static=tbb,framework=Accelerate,dylib=c++,framework=OpenCL,z
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: Repair wheels
env:
Expand All @@ -173,7 +185,7 @@ jobs:
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-latest-${{ matrix.target }}-py3.11
name: wheels-macos-latest-${{ matrix.target }}-py${{ matrix.python }}
path: dist

sdist:
Expand Down Expand Up @@ -206,6 +218,10 @@ jobs:
target: x86_64
manylinux: manylinux_2_35
python: '3.12'
- os: ubuntu-22.04
target: x86_64
manylinux: manylinux_2_35
python: '3.13'
# Ubuntu 24.04 (libc 2.39)
- os: ubuntu-24.04
target: x86_64
Expand All @@ -215,10 +231,22 @@ jobs:
target: x86_64
manylinux: manylinux_2_39
python: '3.12'
- os: ubuntu-24.04
target: x86_64
manylinux: manylinux_2_39
python: '3.13'
- os: macos-latest
target: aarch64
manylinux: ''
python: '3.11'
- os: macos-latest
target: aarch64
manylinux: ''
python: '3.12'
- os: macos-latest
target: aarch64
manylinux: ''
python: '3.13'
steps:
- uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -253,6 +281,9 @@ jobs:
run: |
echo "Built wheels:"
ls -la dist/
- name: Prune unsupported linux-tag wheels
run: |
find dist -type f -name '*.linux_*.whl' -print -delete
- name: Publish to PyPI
uses: pypa/[email protected]
with:
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ authors = [{name = "bghira", email = "[email protected]"}]
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
dependencies = ["numpy>=1.21.0", "pillow>=8.0.0"]
description = "High-performance Rust reimplementation of GIL-blocking video/image operations"
Expand Down Expand Up @@ -35,7 +38,7 @@ extend-exclude = '''
'''
include = '\.pyi?$'
line-length = 88
target-version = ['py311']
target-version = ['py311', 'py312', 'py313']

[tool.isort]
ensure_newline_before_comments = true
Expand Down
30 changes: 3 additions & 27 deletions scripts/build-opencv-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
BUILD_DIR="${PROJECT_ROOT}/opencv-build-tmp"
INSTALL_DIR="${PROJECT_ROOT}/third_party/opencv-static"
SIGNATURE_FILE="${INSTALL_DIR}/build_signature.txt"
BUILD_SIGNATURE="opencv-${OPENCV_VERSION}-static-codecs-jasper-ffmpeg-no-itt-no-openjpeg-tbb-xopen-carotene"
BUILD_SIGNATURE="opencv-${OPENCV_VERSION}-static-codecs-jasper-ffmpeg-no-itt-no-openjpeg-no-tbb"

FFMPEG_BUILD_DIR="${PROJECT_ROOT}/ffmpeg-build-tmp"
FFMPEG_INSTALL_DIR="${PROJECT_ROOT}/third_party/ffmpeg-static"
Expand All @@ -24,11 +24,6 @@ echo "Install directory: ${INSTALL_DIR}"
# Skip rebuild when signature matches desired configuration
if [ -d "${INSTALL_DIR}/lib" ] && [ -f "${INSTALL_DIR}/lib/libopencv_world.a" ] && [ -f "${SIGNATURE_FILE}" ]; then
if grep -qx "${BUILD_SIGNATURE}" "${SIGNATURE_FILE}"; then
# Ensure the promoted TBB archive exists for callers linking against it.
if [ -f "${INSTALL_DIR}/lib/opencv4/3rdparty/libtbb.a" ] && [ ! -f "${INSTALL_DIR}/lib/libtbb.a" ]; then
cp -f "${INSTALL_DIR}/lib/opencv4/3rdparty/libtbb.a" "${INSTALL_DIR}/lib/libtbb.a"
fi

echo "Static OpenCV already built at ${INSTALL_DIR} (signature match)"
exit 0
fi
Expand Down Expand Up @@ -179,29 +174,16 @@ CMAKE_ARGS=(
-DWITH_QT=OFF
-DWITH_OPENEXR=OFF
-DWITH_ITT=OFF
-DBUILD_TBB=ON
-DWITH_TBB=ON
-DBUILD_TBB=OFF
-DWITH_TBB=OFF
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
)

if [[ "$(uname)" == "Darwin" ]]; then
echo "Detected macOS host; disabling oneTBB context switching to avoid macOS 14+ ucontext deprecation."
echo "Detected macOS host; disabling Carotene to avoid linking issue."
CMAKE_ARGS+=(
-DTBB_DISABLE_CONTEXT_SWITCHING=ON
-DWITH_CAROTENE=OFF
)

# macOS 14+ requires defining _XOPEN_SOURCE to access deprecated ucontext APIs used by oneTBB.
XOPEN_FLAG="-D_XOPEN_SOURCE=1"
case "${CFLAGS:-}" in
*-D_XOPEN_SOURCE=*) ;;
*) export CFLAGS="${CFLAGS:+${CFLAGS} }${XOPEN_FLAG}" ;;
esac
case "${CXXFLAGS:-}" in
*-D_XOPEN_SOURCE=*) ;;
*) export CXXFLAGS="${CXXFLAGS:+${CXXFLAGS} }${XOPEN_FLAG}" ;;
esac
fi

cmake "${CMAKE_ARGS[@]}"
Expand Down Expand Up @@ -243,12 +225,6 @@ for mapping in "${CODEC_MAPPINGS[@]}"; do
ln -sf "${CANONICAL_NAME}" "${INSTALL_DIR}/lib/${LINK_NAME}"
done

# Promote Intel TBB static library into the top-level lib directory for easier linking.
TBB_ARCHIVE="${INSTALL_DIR}/lib/opencv4/3rdparty/libtbb.a"
if [ -f "${TBB_ARCHIVE}" ]; then
cp -f "${TBB_ARCHIVE}" "${INSTALL_DIR}/lib/libtbb.a"
fi

# Copy FFmpeg static archives
declare -a FFMPEG_ARCHIVES=(
"libavcodec.a"
Expand Down