diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml index bd42944c..98ad3dc8 100644 --- a/.github/workflows/build_wheels_linux.yml +++ b/.github/workflows/build_wheels_linux.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - 3.4 paths-ignore: - '.github/workflows/build_wheels_linux_arm.yml' - '.github/workflows/build_wheels_windows*' @@ -14,21 +15,18 @@ on: jobs: build: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-20.04 defaults: run: shell: bash - strategy: fail-fast: false matrix: - os: [ubuntu-latest] python-version: ['3.6'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true REPO_DIR: . @@ -39,34 +37,32 @@ jobs: MB_ML_VER: 2014 TRAVIS_BUILD_DIR: ${{ github.workspace }} CONFIG_PATH: travis_config.sh - DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT} - USE_CCACHE: 1 + DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220628 + USE_CCACHE: 0 UNICODE_WIDTH: 32 PLAT: x86_64 SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} - steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Update submodules if: github.event_name == 'pull_request' run: git submodule update --remote - - name: Build a package run: source scripts/build.sh - - name: Saving all wheels uses: actions/upload-artifact@v2 with: name: wheels path: wheelhouse/opencv*.whl - - name: Saving a wheel accordingly to matrix uses: actions/upload-artifact@v2 with: @@ -75,21 +71,18 @@ jobs: test: needs: [build] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-20.04 defaults: run: shell: bash - strategy: fail-fast: false matrix: - os: [ubuntu-latest] python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true MB_PYTHON_VERSION: ${{ matrix.python-version }} @@ -97,42 +90,38 @@ jobs: NP_TEST_DEP_LATEST: numpy==1.21.2 CONFIG_PATH: travis_config.sh PLAT: x86_64 - steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: - submodules: false + submodules: true fetch-depth: 0 - - name: Setup Environment variables run: if [ "3.10" == "${{ 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@v2 with: name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} path: wheelhouse/ - - name: Package installation and run tests run: source scripts/install.sh build_sdist: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-20.04 defaults: run: shell: bash - strategy: fail-fast: false matrix: - os: [ubuntu-latest] python-version: [3.8] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [1] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true REPO_DIR: . @@ -145,30 +134,29 @@ jobs: NP_TEST_DEP: numpy==1.19.4 TRAVIS_BUILD_DIR: ${{ github.workspace }} CONFIG_PATH: travis_config.sh - DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT} + DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220628 USE_CCACHE: 1 UNICODE_WIDTH: 32 SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui || 0 }} ENABLE_CONTRIB: ${{ matrix.with_contrib || 0 }} - steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Update submodules if: github.event_name == 'pull_request' run: git submodule update --remote - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform }} - - name: Build a package run: | set -e @@ -176,12 +164,11 @@ jobs: set -x python -m pip install --upgrade pip python -m pip install scikit-build - python setup.py sdist + python setup.py sdist --formats=gztar set +x # Install and run tests set -x echo "skipping tests because of sdist" - - name: saving artifacts uses: actions/upload-artifact@v2 with: @@ -191,7 +178,7 @@ jobs: test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build, build_sdist, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: test-opencv-python-release defaults: run: @@ -201,7 +188,6 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload all wheels run: | python -m pip install twine @@ -210,7 +196,7 @@ jobs: release_opencv_python: if: github.event_name == 'release' && !github.event.release.prerelease needs: [build, build_sdist, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: opencv-python-release defaults: run: @@ -220,22 +206,18 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload wheels for opencv_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* wheelhouse/opencv-python-[^h]* - - name: Upload wheels for opencv_contrib_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* wheelhouse/opencv-contrib-python-[^h]* - - name: Upload wheels for opencv_python_headless run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* wheelhouse/opencv-python-headless-* - - name: Upload wheels for opencv_contrib_python_headless run: | python -m pip install twine diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml index a97bbc29..4d0c3daf 100644 --- a/.github/workflows/build_wheels_linux_arm.yml +++ b/.github/workflows/build_wheels_linux_arm.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - 3.4 paths-ignore: - '.github/workflows/build_wheels_linux.yml' - '.github/workflows/build_wheels_windows*' @@ -14,21 +15,18 @@ on: jobs: build_arm: - runs-on: ${{ matrix.os }} + runs-on: opencv-cn-lin-arm64 defaults: run: shell: bash - strategy: fail-fast: false matrix: - os: [ARM64] python-version: ['3.6'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true REPO_DIR: . @@ -40,33 +38,30 @@ jobs: MB_ML_VER: 2014 TRAVIS_BUILD_DIR: ${{ github.workspace }} CONFIG_PATH: travis_config.sh - DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT} + DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64:20220628 USE_CCACHE: 0 UNICODE_WIDTH: 32 SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} - steps: + - name: UID + run: id -u - name: Cleanup - if: always() - uses: AutoModality/action-clean@v1 - + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Build a package run: source scripts/build.sh - - name: Saving all wheels uses: actions/upload-artifact@v2 with: name: wheels path: wheelhouse/opencv*.whl - - name: Saving a wheel accordingly to matrix uses: actions/upload-artifact@v2 with: @@ -75,21 +70,18 @@ jobs: test: needs: [build_arm] - runs-on: ${{ matrix.os }} + runs-on: opencv-cn-lin-arm64 defaults: run: shell: bash - strategy: fail-fast: false matrix: - os: [ARM64] python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true MB_PYTHON_VERSION: ${{ matrix.python-version }} @@ -99,34 +91,29 @@ jobs: CONFIG_PATH: travis_config.sh DOCKER_TEST_IMAGE: multibuild/focal_arm64v8 UNICODE_WIDTH: 32 - steps: - name: Cleanup - if: always() - uses: AutoModality/action-clean@v1 - + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: true fetch-depth: 0 - - name: Setup Environment variables run: if [ "3.10" == "${{ 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@v2 with: name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} path: wheelhouse/ - - name: Package installation and run tests run: source scripts/install.sh test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build_arm, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: test-opencv-python-release defaults: run: @@ -136,7 +123,6 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload all wheels run: | python -m pip install twine @@ -145,7 +131,7 @@ jobs: release_opencv_python: if: github.event_name == 'release' && !github.event.release.prerelease needs: [build_arm, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: opencv-python-release defaults: run: @@ -155,22 +141,18 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload wheels for opencv_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* - - name: Upload wheels for opencv_contrib_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* - - name: Upload wheels for opencv_python_headless run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* - - name: Upload wheels for opencv_contrib_python_headless run: | python -m pip install twine diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml index 87fe6f99..af892101 100644 --- a/.github/workflows/build_wheels_macos.yml +++ b/.github/workflows/build_wheels_macos.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - 3.4 paths-ignore: - '.github/workflows/build_wheels_linux*' - '.github/workflows/build_wheels_windows*' @@ -18,7 +19,6 @@ jobs: defaults: run: shell: bash - strategy: fail-fast: false matrix: @@ -39,7 +39,6 @@ jobs: python-version: '3.8' - os: macos-11 python-version: '3.9' - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true REPO_DIR: . @@ -55,21 +54,22 @@ jobs: USE_CCACHE: 1 UNICODE_WIDTH: 32 PLAT: x86_64 + FFMPEG_FORMULA_VERSION: '@4' SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} - steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Update submodules if: github.event_name == 'pull_request' run: git submodule update --remote - - name: Build a package run: | set -e @@ -87,13 +87,11 @@ jobs: echo $ENABLE_HEADLESS > headless.enabled set -x build_wheel $REPO_DIR $PLAT - - name: Saving all wheels uses: actions/upload-artifact@v2 with: name: wheels path: wheelhouse/opencv*.whl - - name: Saving a wheel accordingly to matrix uses: actions/upload-artifact@v2 with: @@ -106,7 +104,6 @@ jobs: defaults: run: shell: bash - strategy: fail-fast: false matrix: @@ -127,7 +124,6 @@ jobs: python-version: '3.8' - os: macos-11 python-version: '3.9' - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true MB_PYTHON_VERSION: ${{ matrix.python-version }} @@ -136,44 +132,47 @@ jobs: CONFIG_PATH: travis_config.sh PLAT: x86_64 OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata - + PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: true fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform }} - - name: Setup Environment variables run: if [ "3.10" == "${{ 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@v2 with: name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} path: wheelhouse/ - - name: Package installation run: | python -m pip install wheelhouse/opencv*.whl cd ${{ github.workspace }}/tests python get_build_info.py - - name: Run tests run: | cd ${{ github.workspace }}/opencv python modules/python/test/test.py -v --repo . + - name: Pylint test + run: | + python -m pip install pylint==2.12.2 + cd ${{ github.workspace }}/tests + python -m pylint $PYLINT_TEST_FILE test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: test-opencv-python-release defaults: run: @@ -183,7 +182,6 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload all wheels run: | python -m pip install twine @@ -192,7 +190,7 @@ jobs: release_opencv_python: if: github.event_name == 'release' && !github.event.release.prerelease needs: [build, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: opencv-python-release defaults: run: @@ -202,22 +200,18 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload wheels for opencv_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* - - name: Upload wheels for opencv_contrib_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* - - name: Upload wheels for opencv_python_headless run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* - - name: Upload wheels for opencv_contrib_python_headless run: | python -m pip install twine diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index 3711e1b3..a1d7c924 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - 3.4 paths-ignore: - '.github/workflows/build_wheels_linux*' - '.github/workflows/build_wheels_windows*' @@ -14,35 +15,32 @@ on: jobs: build: - runs-on: ${{ matrix.os }} - + runs-on: opencv-cn-mac-arm64 strategy: fail-fast: false matrix: - os: [macOS-M1] python-version: ['3.7'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: CI_BUILD: 1 SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} - steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Update submodules if: github.event_name == 'pull_request' run: git submodule update --remote - - name: Build a package run: | git submodule update --init multibuild @@ -52,13 +50,11 @@ jobs: arch -arm64 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 arch -arm64 python${{ matrix.python-version }} setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=wheelhouse -v delocate-wheel ${{ github.workspace }}/wheelhouse/opencv* - - name: Saving all wheels uses: actions/upload-artifact@v2 with: name: wheels path: wheelhouse/opencv*.whl - - name: Saving a wheel accordingly to matrix uses: actions/upload-artifact@v2 with: @@ -67,49 +63,51 @@ jobs: test: needs: [build] - runs-on: ${{ matrix.os }} - + runs-on: opencv-cn-mac-arm64-tests strategy: fail-fast: false matrix: - os: [macOS-M1] python-version: ['3.7', '3.8', '3.9', '3.10'] platform: [x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata - + PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py steps: + - name: Cleanup + run: find . -mindepth 1 -delete + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: true fetch-depth: 0 - - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v2 with: name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }} path: wheelhouse/ - - name: Package installation run: | arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl cd ${{ github.workspace }}/tests arch -arm64 python${{ matrix.python-version }} get_build_info.py - - name: Run tests run: | cd ${{ github.workspace }}/opencv arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo . + - name: Pylint test + run: | + arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2 + cd ${{ github.workspace }}/tests + arch -arm64 python${{ matrix.python-version }} -m pylint $PYLINT_TEST_FILE test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: test-opencv-python-release defaults: run: @@ -128,7 +126,7 @@ jobs: release_opencv_python: if: github.event_name == 'release' && !github.event.release.prerelease needs: [build, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: opencv-python-release defaults: run: @@ -138,7 +136,6 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload wheels for opencv_python run: | python -m pip install twine diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml index 0f697291..087efc04 100644 --- a/.github/workflows/build_wheels_windows.yml +++ b/.github/workflows/build_wheels_windows.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - 3.4 paths-ignore: - '.github/workflows/build_wheels_linux*' - '.github/workflows/build_wheels_macos*' @@ -13,48 +14,43 @@ on: jobs: build-windows-x86_64: - runs-on: ${{ matrix.os }} - defaults: - run: - shell: powershell - + runs-on: windows-2019 strategy: fail-fast: false matrix: - os: [windows-latest] python-version: ['3.6'] platform: [x86, x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata - steps: + - name: Cleanup + shell: bash + run: | + rm -rf ./* || true + rm -rf ./.??* || true + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: false fetch-depth: 0 - - name: Update submodules if: github.event_name == 'pull_request' run: git submodule update --remote - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform }} - - name: Setup MSBuild.exe - uses: warrenbuckley/Setup-MSBuild@v1 - + uses: microsoft/setup-msbuild@v1.1 - name: Build a package run: | python --version @@ -63,13 +59,11 @@ jobs: python -m pip install toml && python -c "import toml; c = toml.load('pyproject.toml'); print('\n'.join(c['build-system']['requires']))" >> requirements.txt | python -m pip install -r requirements.txt set "CI_BUILD=1" && python setup.py bdist_wheel --py-limited-api=cp36 --dist-dir=%cd%\wheelhouse -v shell: cmd - - name: Saving all wheels uses: actions/upload-artifact@v2 with: name: wheels path: wheelhouse/opencv*.whl - - name: Saving a wheel accordingly to matrix uses: actions/upload-artifact@v2 with: @@ -78,44 +72,44 @@ jobs: test: needs: [build-windows-x86_64] - runs-on: ${{ matrix.os }} + runs-on: windows-2019 defaults: run: - shell: powershell - + shell: cmd strategy: fail-fast: false matrix: - os: [windows-latest] python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] platform: [x86, x64] with_contrib: [0, 1] without_gui: [0, 1] build_sdist: [0] - env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata - + PYLINT_TEST_FILE: ${{ github.workspace }}\opencv\samples\python\squares.py steps: + - name: Cleanup + shell: bash + run: | + rm -rf ./* || true + rm -rf ./.??* || true + working-directory: ${{ github.workspace }} - name: Checkout uses: actions/checkout@v2 with: submodules: true fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform }} - - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v2 with: name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }} path: wheelhouse/ - - name: Package installation run: | cd ${{ github.workspace }}/tests @@ -123,17 +117,20 @@ jobs: if ($LastExitCode -ne 0) {throw $LastExitCode} python get_build_info.py shell: powershell - - name: Run tests run: | cd ${{ github.workspace }}/opencv python modules\python\test\test.py -v --repo . - shell: cmd + - name: Pylint test + run: | + python -m pip install pylint==2.12.2 + cd ${{ github.workspace }}\tests + python -m pylint $PYLINT_TEST_FILE test_release_opencv_python: if: github.event_name == 'release' && github.event.release.prerelease needs: [build-windows-x86_64, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: test-opencv-python-release defaults: run: @@ -143,7 +140,6 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload all wheels run: | python -m pip install twine @@ -152,7 +148,7 @@ jobs: release_opencv_python: if: github.event_name == 'release' && !github.event.release.prerelease needs: [build-windows-x86_64, test] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 environment: opencv-python-release defaults: run: @@ -162,22 +158,18 @@ jobs: with: name: wheels path: wheelhouse/ - - name: Upload wheels for opencv_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* - - name: Upload wheels for opencv_contrib_python run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* - - name: Upload wheels for opencv_python_headless run: | python -m pip install twine python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* - - name: Upload wheels for opencv_contrib_python_headless run: | python -m pip install twine diff --git a/.gitmodules b/.gitmodules index 655467e8..7193d3b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/opencv/opencv_contrib.git [submodule "multibuild"] path = multibuild - url = https://github.com/matthew-brett/multibuild.git + url = https://github.com/multi-build/multibuild.git [submodule "opencv_extra"] path = opencv_extra url = https://github.com/opencv/opencv_extra.git diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64 index b380d3ba..2679cbbf 100644 --- a/docker/manylinux2014/Dockerfile_aarch64 +++ b/docker/manylinux2014/Dockerfile_aarch64 @@ -1,80 +1,142 @@ +# Version: 20220628 +# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64 + FROM quay.io/pypa/manylinux2014_aarch64:latest ARG CCACHE_VERSION=3.7.9 ARG FFMPEG_VERSION=4.4.1 +ARG FREETYPE_VERSION=2.12.1 +ARG LIBPNG_VERSION=1.6.37 ARG NASM_VERSION=2.15.04 -ARG OPENSSL_VERSION=1_1_1m +ARG OPENSSL_VERSION=1_1_1o ARG QT_VERSION=5.15.0 ARG YASM_VERSION=1.3.0 -RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y +ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH + +# epel-release need for aarch64 to get openblas packages +RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \ + yum install openblas-devel -y && \ + cp /usr/include/lapacke/lapacke*.h /usr/include/ && \ + curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \ + # libpng will be built from source + yum remove libpng -y + +RUN mkdir ~/libpng_sources && \ + cd ~/libpng_sources && \ + curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \ + tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \ + cd libpng-${LIBPNG_VERSION} && \ + ./configure --prefix=/usr/local && \ + make && \ + make install && \ + cd .. && \ + rm -rf ~/libpng_sources + +RUN mkdir ~/freetype_sources && \ + cd ~/freetype_sources && \ + curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \ + tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \ + cd freetype-${FREETYPE_VERSION} && \ + ./configure --prefix="/ffmpeg_build" --enable-freetype-config && \ + make && \ + make install && \ + cd .. && \ + rm -rf ~/freetype_sources RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \ tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \ - cd qt-everywhere* && \ + cd qt-everywhere-src-${QT_VERSION} && \ export MAKEFLAGS=-j$(nproc) && \ ./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ make && \ make install && \ cd .. && \ - rm -rf qt-everywhere-src-${QT_VERSION} && \ - rm qt-everywhere-src-${QT_VERSION}.tar.xz + rm -rf qt-everywhere* ENV QTDIR /opt/Qt${QT_VERSION} ENV PATH "$QTDIR/bin:$PATH" -RUN mkdir ~/ffmpeg_sources && \ - cd ~/ffmpeg_sources && \ +RUN mkdir ~/openssl_sources && \ + cd ~/openssl_sources && \ curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \ tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \ cd openssl-OpenSSL_${OPENSSL_VERSION} && \ - ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \ + ./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \ make -j$(getconf _NPROCESSORS_ONLN) && \ # skip installing documentation make install_sw && \ - rm -rf ~/openssl_build + cd .. && \ + rm -rf ~/openssl_build ~/openssl_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/nasm_sources && \ + cd ~/nasm_sources && \ curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \ tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \ - ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/nasm_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/yasm_sources && \ + cd ~/yasm_sources && \ curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \ tar -xf yasm-${YASM_VERSION}.tar.gz && \ cd yasm-${YASM_VERSION} && \ - ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/yasm_sources -RUN cd ~/ffmpeg_sources && \ - git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ +RUN mkdir ~/libvpx_sources && \ + cd ~/libvpx_sources && \ + git clone --depth 1 https://github.com/webmproject/libvpx.git && \ cd libvpx && \ - ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ + ./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/libvpx_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/ffmpeg_sources && \ + cd ~/ffmpeg_sources && \ curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \ tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \ cd ffmpeg-${FFMPEG_VERSION} && \ PATH=~/bin:$PATH && \ - PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ + PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ make install && \ - echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ + echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ ldconfig && \ - rm -rf ~/ffmpeg_sources + rm -rf ~/ffmpeg_sources && \ + yum remove bzip2-devel -y RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \ tar -xf ccache-${CCACHE_VERSION}.tar.gz && \ cd ccache-${CCACHE_VERSION} && \ linux32 ./configure && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ccache-${CCACHE_VERSION}.tar.gz + +# Self-hosted runner UID is 1004 +RUN useradd ci -m -s /bin/bash -G users --uid=1004 && \ + mkdir /io && \ + chown -R ci:ci /io && \ + # This needs to find ffmpeg packages from ci user + chown -R ci:ci /ffmpeg_build && \ + # This calls in mutlibuild scripts and cannot be run without permissions + chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel + +USER ci + +# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced +RUN git config --global --add safe.directory /io -ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig -ENV LDFLAGS -L/root/ffmpeg_build/lib +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig +ENV LDFLAGS -L/ffmpeg_build/lib ENV PATH "$HOME/bin:$PATH" diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64 index fb367c0a..8bb77341 100644 --- a/docker/manylinux2014/Dockerfile_x86_64 +++ b/docker/manylinux2014/Dockerfile_x86_64 @@ -1,72 +1,142 @@ +# Version: 20220628 +# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64 + FROM quay.io/pypa/manylinux2014_x86_64:latest +ARG CCACHE_VERSION=3.7.9 ARG FFMPEG_VERSION=4.4.1 +ARG FREETYPE_VERSION=2.12.1 +ARG LIBPNG_VERSION=1.6.37 ARG NASM_VERSION=2.15.04 -ARG OPENSSL_VERSION=1_1_1m +ARG OPENSSL_VERSION=1_1_1o ARG QT_VERSION=5.15.0 ARG YASM_VERSION=1.3.0 -RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y +ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH + +# epel-release need for aarch64 to get openblas packages +RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \ + yum install openblas-devel -y && \ + cp /usr/include/lapacke/lapacke*.h /usr/include/ && \ + curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \ + # libpng will be built from source + yum remove libpng -y + +RUN mkdir ~/libpng_sources && \ + cd ~/libpng_sources && \ + curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \ + tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \ + cd libpng-${LIBPNG_VERSION} && \ + ./configure --prefix=/usr/local && \ + make && \ + make install && \ + cd .. && \ + rm -rf ~/libpng_sources + +RUN mkdir ~/freetype_sources && \ + cd ~/freetype_sources && \ + curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \ + tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \ + cd freetype-${FREETYPE_VERSION} && \ + ./configure --prefix="/ffmpeg_build" --enable-freetype-config && \ + make && \ + make install && \ + cd .. && \ + rm -rf ~/freetype_sources RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \ tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \ - cd qt-everywhere* && \ + cd qt-everywhere-src-${QT_VERSION} && \ export MAKEFLAGS=-j$(nproc) && \ ./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ make && \ make install && \ cd .. && \ - rm -rf qt-everywhere-src-${QT_VERSION} && \ - rm qt-everywhere-src-${QT_VERSION}.tar.xz + rm -rf qt-everywhere* ENV QTDIR /opt/Qt${QT_VERSION} ENV PATH "$QTDIR/bin:$PATH" -RUN mkdir ~/ffmpeg_sources && \ - cd ~/ffmpeg_sources && \ +RUN mkdir ~/openssl_sources && \ + cd ~/openssl_sources && \ curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \ tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \ cd openssl-OpenSSL_${OPENSSL_VERSION} && \ - ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \ + ./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \ make -j$(getconf _NPROCESSORS_ONLN) && \ # skip installing documentation make install_sw && \ - rm -rf ~/openssl_build + cd .. && \ + rm -rf ~/openssl_build ~/openssl_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/nasm_sources && \ + cd ~/nasm_sources && \ curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \ tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \ - ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/nasm_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/yasm_sources && \ + cd ~/yasm_sources && \ curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \ tar -xf yasm-${YASM_VERSION}.tar.gz && \ cd yasm-${YASM_VERSION} && \ - ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/yasm_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/libvpx_sources && \ + cd ~/libvpx_sources && \ git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ cd libvpx && \ - ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ + ./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ make -j$(getconf _NPROCESSORS_ONLN) && \ - make install + make install && \ + cd .. && \ + rm -rf ~/libvpx_sources -RUN cd ~/ffmpeg_sources && \ +RUN mkdir ~/ffmpeg_sources && \ + cd ~/ffmpeg_sources && \ curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \ tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \ cd ffmpeg-${FFMPEG_VERSION} && \ PATH=~/bin:$PATH && \ - PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ + PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ make -j$(getconf _NPROCESSORS_ONLN) && \ make install && \ - echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ + echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ ldconfig && \ - rm -rf ~/ffmpeg_sources + rm -rf ~/ffmpeg_sources && \ + yum remove bzip2-devel -y + +RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \ + tar -xf ccache-${CCACHE_VERSION}.tar.gz && \ + cd ccache-${CCACHE_VERSION} && \ + ./configure && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install && \ + cd .. && \ + rm -rf ccache-${CCACHE_VERSION}.tar.gz + +# GitHub Actions user`s UID is 1001 +RUN useradd ci -m -s /bin/bash -G users --uid=1001 && \ + mkdir /io && \ + chown -R ci:ci /io && \ + # This needs to find ffmpeg packages from ci user + chown -R ci:ci /ffmpeg_build && \ + # This calls in mutlibuild scripts and cannot be run without permissions + chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel + +USER ci + +# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced +RUN git config --global --add safe.directory /io -ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig -ENV LDFLAGS -L/root/ffmpeg_build/lib +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig +ENV LDFLAGS -L/ffmpeg_build/lib ENV PATH "$HOME/bin:$PATH" diff --git a/multibuild b/multibuild index b89bb903..bce1637e 160000 --- a/multibuild +++ b/multibuild @@ -1 +1 @@ -Subproject commit b89bb903e94308be79abefa4f436bf123ebb1313 +Subproject commit bce1637e202cb52b0e7ea42baa1cccc894b82806 diff --git a/opencv b/opencv index dad26339..b0dc4741 160000 --- a/opencv +++ b/opencv @@ -1 +1 @@ -Subproject commit dad26339a975b49cfb6c7dbe4bd5276c9dcb36e2 +Subproject commit b0dc474160e389b9c9045da5db49d03ae17c6a6b diff --git a/opencv_contrib b/opencv_contrib index 49e8f123..db16caf6 160000 --- a/opencv_contrib +++ b/opencv_contrib @@ -1 +1 @@ -Subproject commit 49e8f123ca08e76891856a1ecce491b62d08ba20 +Subproject commit db16caf6ceee76b43b94c846be276e92a43e9700 diff --git a/opencv_extra b/opencv_extra index 37294e3c..936854e2 160000 --- a/opencv_extra +++ b/opencv_extra @@ -1 +1 @@ -Subproject commit 37294e3c876a72c992d4718b9bbfc8346b9e779a +Subproject commit 936854e2b666853d6d0732a8eabc2d699f4fa3d8 diff --git a/pyproject.toml b/pyproject.toml index 6aaab1d3..ff535e86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [build-system] requires = [ - "setuptools", "wheel", "scikit-build", "cmake", "pip", + "setuptools==59.2.0", "wheel==0.37.0", "cmake>=3.1", "pip", + "scikit-build>=0.13.2", "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'", "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'", "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'", diff --git a/setup.py b/setup.py index 5b79e389..11014d6b 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ def main(): ) # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode - x64 = sys.maxsize > 2 ** 32 + is64 = sys.maxsize > 2 ** 32 package_name = "opencv-python" @@ -88,7 +88,7 @@ def main(): # Path regexes with forward slashes relative to CMake install dir. rearrange_cmake_output_data = { "cv2": ( - [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if x64 else "")] + [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if is64 else "")] if os.name == "nt" else [] ) @@ -130,7 +130,7 @@ def main(): files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]} ci_cmake_generator = ( - ["-G", "Visual Studio 14" + (" Win64" if x64 else "")] + ["-G", "Visual Studio 14" + (" Win64" if is64 else "")] if os.name == "nt" else ["-G", "Unix Makefiles"] ) @@ -161,12 +161,17 @@ def main(): "-DBUILD_DOCS=OFF", "-DPYTHON3_LIMITED_API=ON", "-DBUILD_OPENEXR=ON", - "-DBUILD_PNG=ON", ] + ( + # CMake flags for windows/arm64 build + ["-DCMAKE_GENERATOR_PLATFORM=ARM64", + # Emulated cmake requires following flags to correctly detect + # target architecture for windows/arm64 build + "-DOPENCV_WORKAROUND_CMAKE_20989=ON", + "-DCMAKE_SYSTEM_PROCESSOR=ARM64"] + if platform.machine() == "ARM64" and sys.platform == "win32" # If it is not defined 'linker flags: /machine:X86' on Windows x64 - ["-DCMAKE_GENERATOR_PLATFORM=x64"] - if x64 and sys.platform == "win32" + else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32" else [] ) + ( @@ -186,7 +191,7 @@ def main(): "-DWITH_MSMF=OFF" ) # see: https://github.com/skvark/opencv-python/issues/263 - if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv: + if sys.platform.startswith("linux") and not is64 and "bdist_wheel" in sys.argv: subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True) # OS-specific components during CI builds @@ -369,21 +374,6 @@ def _classify_installed_files_override( print("Copying files from CMake output") - # lines for a proper work using pylint and an autocomplete in IDE - with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'r') as opencv_init: - opencv_init_lines = opencv_init.readlines() - extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi' - '\nfrom . import misc\nfrom . import utils\nfrom . import data\nfrom . import version\n') - free_line_after_imports = 6 - opencv_init_lines.insert(free_line_after_imports, extra_imports) - opencv_init_data = "" - for line in opencv_init_lines: - opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")') - opencv_init_data = opencv_init_data + opencv_init_replacement - - with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'w') as opencv_final_init: - opencv_final_init.write(opencv_init_data) - # add lines from the old __init__.py file to the config file with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init: custom_init_data = custom_init.read() @@ -412,7 +402,8 @@ def _classify_installed_files_override( final_install_relpaths.append(new_install_relpath) del m, fslash_relpath, new_install_relpath else: - if not found: + # gapi can be missed if ADE was not downloaded (network issue) + if not found and "gapi" not in relpath_re: raise Exception("Not found: '%s'" % relpath_re) del r, found @@ -451,7 +442,7 @@ def _classify_installed_files_override( data_files, # To get around a check that prepends source dir to paths and breaks package detection code. cmake_source_dir="", - cmake_install_dir=cmake_install_reldir, + _cmake_install_dir=cmake_install_reldir, ) diff --git a/tests/pylintrc b/tests/pylintrc new file mode 100644 index 00000000..a3892018 --- /dev/null +++ b/tests/pylintrc @@ -0,0 +1,12 @@ +# Source: opencv/platforms/scripts/pylintrc + +[MESSAGES CONTROL] + +# Disable all to choose the Tests one by one +disable=all + +# Tests +enable=bad-indentation, # Used when an unexpected number of indentation’s tabulations or spaces has been found. + mixed-indentation, # Used when there are some mixed tabs and spaces in a module. + unnecessary-semicolon, # Used when a statement is ended by a semi-colon (”;”), which isn’t necessary. + unused-variable # Used when a variable is defined but not used. (Use _var to ignore var). diff --git a/travis_config.sh b/travis_config.sh index 7bbfec68..366d35ad 100644 --- a/travis_config.sh +++ b/travis_config.sh @@ -50,7 +50,7 @@ if [ -n "$IS_OSX" ]; then function generate_ffmpeg_formula { local FF="ffmpeg" local LFF="ffmpeg_opencv" - local FF_FORMULA; FF_FORMULA=$(brew formula "$FF") + local FF_FORMULA; FF_FORMULA=$(brew formula "${FF}${FFMPEG_FORMULA_VERSION}") local LFF_FORMULA; LFF_FORMULA="$(dirname "$FF_FORMULA")/${LFF}.rb" local REGENERATE @@ -70,8 +70,9 @@ if [ -n "$IS_OSX" ]; then if [ -n "$REGENERATE" ]; then echo "Regenerating custom ffmpeg formula" # Bottle block syntax: https://docs.brew.sh/Bottles#bottle-dsl-domain-specific-language + # FfmpegAT4 is a class in ffmpeg@4 formula perl -wpe 'BEGIN {our ($found_blank, $bottle_block);} - if (/(^class )(Ffmpeg)(\s.*)/) {$_=$1.$2."Opencv".$3."\n"; next;} + if (/(^class )(FfmpegAT4)(\s.*)/) {$_=$1."FfmpegOpencv".$3."\n"; next;} if (!$found_blank && /^$/) {$_.="conflicts_with \"ffmpeg\"\n\n"; $found_blank=1; next;} if (!$bottle_block && /^\s*bottle do$/) { $bottle_block=1; next; } if ($bottle_block) { if (/^\s*end\s*$/) { $bottle_block=0} elsif (/^\s*sha256\s/) {$_=""} next; } @@ -97,11 +98,6 @@ function pre_build { if [ -n "$IS_OSX" ]; then brew install lapack - else - # epel-release need for aarch64 to get openblas packages - yum install -y lapack-devel epel-release && yum install -y openblas-devel - cp /usr/include/lapacke/lapacke*.h /usr/include/ - curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h fi if [ -n "$IS_OSX" ]; then @@ -111,34 +107,14 @@ function pre_build { CACHE_STAGE= export HOMEBREW_NO_AUTO_UPDATE=1 - #after the cache stage, all bottles and Homebrew metadata should be already cached locally - # if [ -n "$CACHE_STAGE" ]; then - # brew update - # generate_ffmpeg_formula - # brew_add_local_bottles - # fi - echo 'Installing FFmpeg' - # if [ -n "$CACHE_STAGE" ]; then - # brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; } - # else - brew update - generate_ffmpeg_formula - brew_add_local_bottles - # brew unlink python@2 - brew install --build-bottle ffmpeg_opencv - # fi - - # echo 'Installing qt5' - - # if [ -n "$CACHE_STAGE" ]; then - # echo "Qt5 has bottle, no caching needed" - # else - # brew switch qt 5.13.2 - # brew pin qt - # export PATH="/usr/local/opt/qt/bin:$PATH" - # fi + brew update + generate_ffmpeg_formula + brew_add_local_bottles + brew install --build-bottle ffmpeg_opencv + # It needs when we use not the latest ffmpeg formula + brew link ffmpeg_opencv if [ -n "$CACHE_STAGE" ]; then brew_go_bootstrap_mode 0 @@ -160,37 +136,37 @@ function run_tests { PYTHON=python$PYTHON_VERSION - if [ -n "$IS_OSX" ]; then - echo "Running for OS X" - - cd ../tests - $PYTHON get_build_info.py - - cd ../opencv/ - export OPENCV_TEST_DATA_PATH=../opencv_extra/testdata - else - echo "Running for linux" - - if [ $PYTHON == "python3.6" ]; then - $PYTHON -m pip install -U numpy==1.19.4 - fi - cd /io/tests - $PYTHON get_build_info.py + echo "Running for linux" - cd /io/opencv - export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata + if [ $PYTHON == "python3.6" ]; then + $PYTHON -m pip install -U numpy==1.19.4 fi + cd /io/tests + $PYTHON get_build_info.py + + cd /io/opencv + export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata test_wheels + pylint_test } function test_wheels { - echo "Starting tests..." + echo "Starting OpenCV tests..." #Test package $PYTHON modules/python/test/test.py -v --repo . } +function pylint_test { + + echo "Starting Pylint tests..." + + $PYTHON -m pip install pylint==2.12.2 + cd /io/tests + $PYTHON -m pylint /io/opencv/samples/python/squares.py +} + export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' set -x