Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Build Mac arm64 configuration with Github cloud. #933

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from
Open
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
67 changes: 56 additions & 11 deletions .github/workflows/build_wheels_macos_m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ on:

jobs:
Build:
runs-on: python-macos11-m1
runs-on: macos-12
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
Expand All @@ -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 }}
Expand All @@ -44,20 +58,35 @@ 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:
submodules: false
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:
Expand All @@ -71,7 +100,10 @@ jobs:

Test:
needs: [Build]
runs-on: opencv-cn-mac-arm64-tests
runs-on: macos-12
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
Expand All @@ -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
Expand All @@ -93,25 +131,32 @@ 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:
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
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' }}
Expand Down
Loading