diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml index 9df69240..7bfe8cec 100644 --- a/.github/workflows/build_wheels_linux.yml +++ b/.github/workflows/build_wheels_linux.yml @@ -58,10 +58,10 @@ jobs: echo "ENABLE_ROLLING=1" >> $GITHUB_ENV fi - name: Checkout - run: | - echo "Source branch name: ${{ github.head_ref }}" - echo "Target branch name: ${{ github.base_ref }}" - git clone --depth 1 -b "${{ github.head_ref }}" "https://github.com/${{ github.event.pull_request.head.repo.full_name }}" "${{ github.workspace }}" + uses: actions/checkout@v3 + with: + submodules: false + fetch-depth: 0 - name: Build a package run: source scripts/build.sh - name: Saving all wheels @@ -84,7 +84,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] @@ -93,7 +93,7 @@ jobs: ACTIONS_ALLOW_UNSECURE_COMMANDS: true MB_PYTHON_VERSION: ${{ matrix.python-version }} NP_TEST_DEP: numpy==1.19.4 - NP_TEST_DEP_LATEST: numpy==2.0.0 + NP_TEST_DEP_LATEST: numpy==2.2.1 CONFIG_PATH: travis_config.sh PLAT: x86_64 steps: @@ -101,12 +101,12 @@ jobs: run: find . -mindepth 1 -delete working-directory: ${{ github.workspace }} - name: Checkout - run: | - echo "Source branch name: ${{ github.head_ref }}" - echo "Target branch name: ${{ github.base_ref }}" - git clone --depth 1 --recurse-submodules -b "${{ github.head_ref }}" "https://github.com/${{ github.event.pull_request.head.repo.full_name }}" "${{ github.workspace }}" + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 - name: Setup Environment variables - run: if [ "3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi + run: if [ "3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" -o "3.13" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v3 with: @@ -155,10 +155,10 @@ jobs: echo "ENABLE_ROLLING=1" >> $GITHUB_ENV fi - name: Checkout - run: | - echo "Source branch name: ${{ github.head_ref }}" - echo "Target branch name: ${{ github.base_ref }}" - git clone --depth 1 -b "${{ github.head_ref }}" "https://github.com/${{ github.event.pull_request.head.repo.full_name }}" "${{ github.workspace }}" + uses: actions/checkout@v3 + with: + submodules: false + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml index bd5c0040..d643ba8e 100644 --- a/.github/workflows/build_wheels_linux_arm.yml +++ b/.github/workflows/build_wheels_linux_arm.yml @@ -58,10 +58,10 @@ jobs: echo "ENABLE_ROLLING=1" >> $GITHUB_ENV fi - name: Checkout - run: | - echo "Source branch name: ${{ github.head_ref }}" - echo "Target branch name: ${{ github.base_ref }}" - git clone --depth 1 -b "${{ github.head_ref }}" "https://github.com/${{ github.event.pull_request.head.repo.full_name }}" "${{ github.workspace }}" + uses: actions/checkout@v3 + with: + submodules: false + fetch-depth: 0 - name: Build a package run: source scripts/build.sh - name: Saving all wheels @@ -84,7 +84,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] @@ -94,7 +94,7 @@ jobs: MB_PYTHON_VERSION: ${{ matrix.python-version }} PLAT: aarch64 NP_TEST_DEP: numpy==1.19.4 - NP_TEST_DEP_LATEST: numpy==2.0.0 + NP_TEST_DEP_LATEST: numpy==2.2.1 CONFIG_PATH: travis_config.sh DOCKER_TEST_IMAGE: multibuild/focal_arm64v8 UNICODE_WIDTH: 32 @@ -103,12 +103,12 @@ jobs: run: find . -mindepth 1 -delete working-directory: ${{ github.workspace }} - name: Checkout - run: | - echo "Source branch name: ${{ github.head_ref }}" - echo "Target branch name: ${{ github.base_ref }}" - git clone --depth 1 --recurse-submodules -b "${{ github.head_ref }}" "https://github.com/${{ github.event.pull_request.head.repo.full_name }}" "${{ github.workspace }}" + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 - name: Setup Environment variables - run: if [ "3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi + run: if [ "3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" -o "3.13" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index 6940cc55..eb797d46 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -105,7 +105,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] @@ -114,7 +114,7 @@ jobs: ACTIONS_ALLOW_UNSECURE_COMMANDS: true MB_PYTHON_VERSION: ${{ matrix.python-version }} NP_TEST_DEP: numpy==1.19.4 - NP_TEST_DEP_LATEST: numpy==2.0.0 + NP_TEST_DEP_LATEST: numpy==2.2.1 CONFIG_PATH: travis_config.sh PLAT: x86_64 OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata @@ -134,7 +134,7 @@ jobs: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform }} - name: Setup Environment variables - run: if [ "3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi + run: if ["3.10" == "${{ matrix.python-version }}" -o "3.11" == "${{ matrix.python-version }}" -o "3.12" == "${{ matrix.python-version }}" -o "3.13" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index dd119fcb..ffbdc752 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -54,7 +54,7 @@ jobs: git submodule update --init multibuild echo $ENABLE_CONTRIB > contrib.enabled echo $ENABLE_HEADLESS > headless.enabled - export MACOSX_DEPLOYMENT_TARGET=11.0 + export MACOSX_DEPLOYMENT_TARGET=13.0 python${{ matrix.python-version }} -m pip install toml && python${{ matrix.python-version }} -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | python${{ matrix.python-version }} -m pip install -r /dev/stdin python${{ matrix.python-version }} setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=wheelhouse -v delocate-wheel ${{ github.workspace }}/wheelhouse/opencv* @@ -71,11 +71,11 @@ jobs: Test: needs: [Build] - runs-on: opencv-cn-mac-arm64-tests + runs-on: python-macos12-m1 strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index d69f17ec..bb7b548b 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -59,6 +59,8 @@ jobs: architecture: ${{ matrix.platform }} - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.1 + - name: Setup NASM + uses: ilammy/setup-nasm@v1 - name: Build a package # CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version run: | @@ -89,7 +91,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] platform: [x86, x64] with_contrib: [0, 1] without_gui: [0, 1] diff --git a/MANIFEST.in b/MANIFEST.in index b429eae0..cb9a7e7b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include README.md include find_version.py include setup.py include pyproject.toml +include _build_backend/backend.py recursive-include cv2 * recursive-include docker * recursive-include opencv * diff --git a/_build_backend/backend.py b/_build_backend/backend.py new file mode 100644 index 00000000..7fc84138 --- /dev/null +++ b/_build_backend/backend.py @@ -0,0 +1,23 @@ +from setuptools import build_meta as _orig + +prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel +build_wheel = _orig.build_wheel +build_sdist = _orig.build_sdist +get_requires_for_build_sdist = _orig.get_requires_for_build_sdist + +def get_requires_for_build_wheel(config_settings=None): + from packaging import version + from skbuild.exceptions import SKBuildError + from skbuild.cmaker import get_cmake_version + packages = _orig.get_requires_for_build_wheel(config_settings) + # check if system cmake can be used if present + # if not, append cmake PyPI distribution to required packages + # scikit-build>=0.18 itself requires cmake 3.5+ + min_version = "3.5" + try: + if version.parse(get_cmake_version().split("-")[0]) < version.parse(min_version): + packages.append(f'cmake>={min_version}') + except SKBuildError: + packages.append(f'cmake>={min_version}') + + return packages diff --git a/opencv b/opencv index b42075f3..31b0eeea 160000 --- a/opencv +++ b/opencv @@ -1 +1 @@ -Subproject commit b42075f3e2c7eca4a12e55b32cfc95fa90982a21 +Subproject commit 31b0eeea0b44b370fd0712312df4214d4ae1b158 diff --git a/opencv_contrib b/opencv_contrib index 3e776c87..0e5254eb 160000 --- a/opencv_contrib +++ b/opencv_contrib @@ -1 +1 @@ -Subproject commit 3e776c876ef8527ad639d2c792521b6cede291e5 +Subproject commit 0e5254ebf54d2aed6e7eaf6660bf3b797cf50a02 diff --git a/pyproject.toml b/pyproject.toml index 71de7f9b..d70b49ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,18 @@ [build-system] requires = [ - "cmake>=3.1", "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'", "numpy==1.17.0; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'", "numpy==1.17.5; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'", "numpy==1.19.3; python_version<'3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'", "numpy==1.21.0; python_version<'3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'", "numpy>=2.0.0; python_version>='3.9'", + "packaging", "pip", "scikit-build>=0.14.0", - "setuptools==59.2.0", + "setuptools==59.2.0; python_version<'3.12'", + "setuptools<70.0.0; python_version>='3.12'", ] +# use a custom backend to manage CMake check / installation +# see https://scikit-build.readthedocs.io/en/latest/usage.html#adding-cmake-as-building-requirement-only-if-not-installed-or-too-low-a-version +build-backend = "backend" +backend-path = ["_build_backend"] diff --git a/setup.py b/setup.py index fd4181d0..1dfab2fb 100644 --- a/setup.py +++ b/setup.py @@ -118,8 +118,11 @@ def main(): # In Windows, in python/X.Y//; in Linux, in just python/X.Y/. # Naming conventions vary so widely between versions and OSes # had to give up on checking them. + # If not specifying PY_LIMITED_API, the Python sources go under python/cv2/python-3.MINOR_VERSION/ instead of python/cv2/python-3/ [ - r"python/cv2/python-%s/cv2.*" + r"python/cv2/python-%s*/cv2.*" + % (sys.version_info[0]) if 'CMAKE_ARGS' in os.environ and "-DPYTHON3_LIMITED_API=ON" in os.environ['CMAKE_ARGS'] + else r"python/cv2/python-%s.*/cv2.*" % (sys.version_info[0]) ] + @@ -300,6 +303,7 @@ def main(): "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: C++", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Scientific/Engineering",