Skip to content

Commit 3277c47

Browse files
committed
Build Mac arm64 configuration with Github cloud.
1 parent ea3538a commit 3277c47

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

.github/workflows/build_wheels_macos_m1.yml

+56-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ on:
2020

2121
jobs:
2222
Build:
23-
runs-on: python-macos11-m1
23+
runs-on: macos-12-large
24+
defaults:
25+
run:
26+
shell: bash
2427
strategy:
2528
fail-fast: false
2629
matrix:
@@ -30,7 +33,18 @@ jobs:
3033
without_gui: [0, 1]
3134
build_sdist: [0]
3235
env:
33-
CI_BUILD: 1
36+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
37+
REPO_DIR: .
38+
PROJECT_SPEC: opencv-python
39+
MB_PYTHON_VERSION: ${{ matrix.python-version }}
40+
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
41+
MB_ML_VER: 2014
42+
TRAVIS_BUILD_DIR: ${{ github.workspace }}
43+
TRAVIS_OS_NAME: osx
44+
CONFIG_PATH: travis_config.sh
45+
USE_CCACHE: 1
46+
UNICODE_WIDTH: 32
47+
PLAT: arm64
3448
SDIST: ${{ matrix.build_sdist || 0 }}
3549
ENABLE_HEADLESS: ${{ matrix.without_gui }}
3650
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
@@ -44,20 +58,35 @@ jobs:
4458
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
4559
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
4660
fi
61+
# hack for image issue on mac: https://github.com/actions/runner-images/issues/6817
62+
rm /usr/local/bin/2to3*
63+
rm /usr/local/bin/idle3*
64+
rm /usr/local/bin/pydoc3*
65+
rm /usr/local/bin/python3*
66+
# end hack
4767
- name: Checkout
4868
uses: actions/checkout@v3
4969
with:
5070
submodules: false
5171
fetch-depth: 0
5272
- name: Build a package
5373
run: |
74+
set -e
75+
# Check out and prepare the source
76+
# Multibuild doesn't have releases, so --depth would break eventually (see
77+
# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
5478
git submodule update --init multibuild
79+
source multibuild/common_utils.sh
80+
# https://github.com/matthew-brett/multibuild/issues/116
81+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
82+
source multibuild/travis_steps.sh
83+
# This sets -x
84+
# source travis_multibuild_customize.sh
5585
echo $ENABLE_CONTRIB > contrib.enabled
5686
echo $ENABLE_HEADLESS > headless.enabled
5787
export MACOSX_DEPLOYMENT_TARGET=11.0
58-
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
59-
arch -arm64 python${{ matrix.python-version }} setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=wheelhouse -v
60-
delocate-wheel ${{ github.workspace }}/wheelhouse/opencv*
88+
set -x
89+
build_wheel $REPO_DIR $PLAT
6190
- name: Saving all wheels
6291
uses: actions/upload-artifact@v3
6392
with:
@@ -71,7 +100,10 @@ jobs:
71100

72101
Test:
73102
needs: [Build]
74-
runs-on: opencv-cn-mac-arm64-tests
103+
runs-on: macos-12-large
104+
defaults:
105+
run:
106+
shell: bash
75107
strategy:
76108
fail-fast: false
77109
matrix:
@@ -81,6 +113,12 @@ jobs:
81113
without_gui: [0, 1]
82114
build_sdist: [0]
83115
env:
116+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
117+
MB_PYTHON_VERSION: ${{ matrix.python-version }}
118+
NP_TEST_DEP: numpy==1.21.0
119+
NP_TEST_DEP_LATEST: numpy==1.26.0
120+
CONFIG_PATH: travis_config.sh
121+
PLAT: arm64
84122
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
85123
PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
86124
PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
@@ -93,25 +131,32 @@ jobs:
93131
with:
94132
submodules: true
95133
fetch-depth: 0
134+
- name: Set up Python ${{ matrix.python-version }}
135+
uses: actions/setup-python@v4
136+
with:
137+
python-version: ${{ matrix.python-version }}
138+
architecture: ${{ matrix.platform }}
139+
- name: Setup Environment variables
140+
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
96141
- name: Download a wheel accordingly to matrix
97142
uses: actions/download-artifact@v3
98143
with:
99144
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
100145
path: wheelhouse/
101146
- name: Package installation
102147
run: |
103-
arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl
148+
python -m pip install wheelhouse/opencv*.whl
104149
cd ${{ github.workspace }}/tests
105-
arch -arm64 python${{ matrix.python-version }} get_build_info.py
150+
python get_build_info.py
106151
- name: Run tests
107152
run: |
108153
cd ${{ github.workspace }}/opencv
109-
arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
154+
python modules/python/test/test.py -v --repo .
110155
- name: Pylint test
111156
run: |
112-
arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.15.9
157+
python -m pip install pylint==2.15.9
113158
cd ${{ github.workspace }}/tests
114-
arch -arm64 python${{ matrix.python-version }} -m pylint $PYLINT_TEST_FILE
159+
python -m pylint $PYLINT_TEST_FILE
115160
116161
Release_rolling:
117162
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}

0 commit comments

Comments
 (0)