diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a825d6..cf3ae99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 972d177..35818c1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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: @@ -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 @@ -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: @@ -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/gh-action-pypi-publish@v1.12.4 with: diff --git a/pyproject.toml b/pyproject.toml index 5c264a4..a4ea20f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,10 @@ authors = [{name = "bghira", email = "bghira@users.noreply.github.com"}] 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" @@ -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 diff --git a/scripts/build-opencv-static.sh b/scripts/build-opencv-static.sh index 322dc26..1bdac39 100755 --- a/scripts/build-opencv-static.sh +++ b/scripts/build-opencv-static.sh @@ -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" @@ -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 @@ -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[@]}" @@ -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"