From 3277c47151dc318d044421524460857a3a97a713 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 26 Dec 2023 17:26:14 +0300 Subject: [PATCH] Build Mac arm64 configuration with Github cloud. --- .github/workflows/build_wheels_macos_m1.yml | 67 +++++++++++++++++---- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml index 5d638fd8..80b8cdf1 100644 --- a/.github/workflows/build_wheels_macos_m1.yml +++ b/.github/workflows/build_wheels_macos_m1.yml @@ -20,7 +20,10 @@ on: jobs: Build: - runs-on: python-macos11-m1 + runs-on: macos-12-large + defaults: + run: + shell: bash strategy: fail-fast: false matrix: @@ -30,7 +33,18 @@ jobs: without_gui: [0, 1] build_sdist: [0] env: - CI_BUILD: 1 + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + REPO_DIR: . + PROJECT_SPEC: opencv-python + MB_PYTHON_VERSION: ${{ matrix.python-version }} + TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }} + MB_ML_VER: 2014 + TRAVIS_BUILD_DIR: ${{ github.workspace }} + TRAVIS_OS_NAME: osx + CONFIG_PATH: travis_config.sh + USE_CCACHE: 1 + UNICODE_WIDTH: 32 + PLAT: arm64 SDIST: ${{ matrix.build_sdist || 0 }} ENABLE_HEADLESS: ${{ matrix.without_gui }} ENABLE_CONTRIB: ${{ matrix.with_contrib }} @@ -44,6 +58,12 @@ jobs: if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "ENABLE_ROLLING=1" >> $GITHUB_ENV fi + # hack for image issue on mac: https://github.com/actions/runner-images/issues/6817 + rm /usr/local/bin/2to3* + rm /usr/local/bin/idle3* + rm /usr/local/bin/pydoc3* + rm /usr/local/bin/python3* + # end hack - name: Checkout uses: actions/checkout@v3 with: @@ -51,13 +71,22 @@ jobs: fetch-depth: 0 - name: Build a package run: | + set -e + # Check out and prepare the source + # Multibuild doesn't have releases, so --depth would break eventually (see + # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised) git submodule update --init multibuild + source multibuild/common_utils.sh + # https://github.com/matthew-brett/multibuild/issues/116 + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi + source multibuild/travis_steps.sh + # This sets -x + # source travis_multibuild_customize.sh echo $ENABLE_CONTRIB > contrib.enabled echo $ENABLE_HEADLESS > headless.enabled export MACOSX_DEPLOYMENT_TARGET=11.0 - 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* + set -x + build_wheel $REPO_DIR $PLAT - name: Saving all wheels uses: actions/upload-artifact@v3 with: @@ -71,7 +100,10 @@ jobs: Test: needs: [Build] - runs-on: opencv-cn-mac-arm64-tests + runs-on: macos-12-large + defaults: + run: + shell: bash strategy: fail-fast: false matrix: @@ -81,6 +113,12 @@ jobs: without_gui: [0, 1] build_sdist: [0] env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + MB_PYTHON_VERSION: ${{ matrix.python-version }} + NP_TEST_DEP: numpy==1.21.0 + NP_TEST_DEP_LATEST: numpy==1.26.0 + CONFIG_PATH: travis_config.sh + PLAT: arm64 OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple @@ -93,6 +131,13 @@ jobs: with: submodules: true fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + 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 - name: Download a wheel accordingly to matrix uses: actions/download-artifact@v3 with: @@ -100,18 +145,18 @@ jobs: path: wheelhouse/ - name: Package installation run: | - arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl + python -m pip install wheelhouse/opencv*.whl cd ${{ github.workspace }}/tests - arch -arm64 python${{ matrix.python-version }} get_build_info.py + python 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 . + python modules/python/test/test.py -v --repo . - name: Pylint test run: | - arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.15.9 + python -m pip install pylint==2.15.9 cd ${{ github.workspace }}/tests - arch -arm64 python${{ matrix.python-version }} -m pylint $PYLINT_TEST_FILE + python -m pylint $PYLINT_TEST_FILE Release_rolling: if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}