Skip to content

Commit 6f7f83a

Browse files
committed
Merge branch 'mac_arm64_wheels' into main
2 parents d05c37a + 82f022b commit 6f7f83a

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

.github/workflows/main.yml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
needs: build-docstrings
6868
strategy:
6969
matrix:
70-
os: [ubuntu-latest, windows-2019, macos-latest]
70+
os: [ubuntu-latest, windows-latest, macos-latest]
7171
runs-on: ${{ matrix.os }}
7272
steps:
7373
- name: Print home directory
@@ -239,7 +239,9 @@ jobs:
239239
path: ~/.hunter
240240
key: hunter-macos-latest
241241
- name: List .hunter cache directory
242-
run: ls -a -l ~/.hunter/_Base/ || true
242+
run: |
243+
ls -a -l ~/.hunter/_Base/ || true
244+
echo "PATH=$PATH"
243245
244246
- uses: actions/checkout@v2
245247
with:
@@ -283,6 +285,63 @@ jobs:
283285
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
284286
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
285287

288+
# This job builds wheels for macOS arm64 arch
289+
build-macos-arm64:
290+
needs: build-docstrings
291+
runs-on: [self-hosted, macOS, ARM64]
292+
steps:
293+
# Cached locally on runner
294+
# - name: Cache .hunter folder
295+
# uses: actions/cache@v2
296+
# with:
297+
# path: ~/.hunter
298+
# key: hunter-macos-latest
299+
- name: List .hunter cache directory
300+
run: |
301+
ls -a -l ~/.hunter/_Base/ || true
302+
echo "PATH=$PATH"
303+
304+
- uses: actions/checkout@v2
305+
with:
306+
submodules: 'recursive'
307+
308+
- uses: actions/download-artifact@v2
309+
with:
310+
name: 'docstrings'
311+
path: docstrings
312+
- name: Specify docstring to use while building the wheel
313+
run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/docstrings/depthai_python_docstring.hpp" >> $GITHUB_ENV
314+
315+
- name: Append build hash if not a tagged commit
316+
if: startsWith(github.ref, 'refs/tags/v') != true
317+
run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV
318+
319+
# - name: Build and install depthai-core
320+
# run: |
321+
# echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
322+
# cmake -S depthai-core/ -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake
323+
# cmake --build build_core --target install --parallel 4
324+
# echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV
325+
326+
- name: Build wheels
327+
run: for PYBIN in {9..10}; do "python3.${PYBIN}" -m pip wheel . -w wheelhouse/ --verbose; done
328+
329+
- name: Auditing wheels
330+
run: delocate-wheel -v -w wheelhouse/audited wheelhouse/*.whl
331+
332+
- name: Archive wheel artifacts
333+
uses: actions/upload-artifact@v2
334+
with:
335+
name: audited-wheels
336+
path: wheelhouse/audited/
337+
- name: Deploy wheels to artifactory (if not a release)
338+
if: startsWith(github.ref, 'refs/tags/v') != true
339+
run: bash ./ci/upload-artifactory.sh
340+
env:
341+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
342+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
343+
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
344+
286345
# This job builds wheels for x86_64 arch
287346
build-linux-x86_64:
288347
needs: build-docstrings
@@ -406,7 +465,7 @@ jobs:
406465

407466
release:
408467
if: startsWith(github.ref, 'refs/tags/v')
409-
needs: [pytest, build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64, build-linux-arm64]
468+
needs: [pytest, build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-macos-arm64, build-linux-x86_64, build-linux-arm64]
410469
runs-on: ubuntu-latest
411470

412471
steps:

examples/install_requirements.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def hasWhitespace(string):
8383
if sys.version_info[0] != 3:
8484
raise RuntimeError("Examples require Python 3 to run (detected: Python {})".format(sys.version_info[0]))
8585

86-
if thisPlatform == "arm64" and platform.system() == "Darwin":
87-
err_str = "There are no prebuilt wheels for M1 processors. Please open the following link for a solution - https://discuss.luxonis.com/d/69-running-depthai-on-apple-m1-based-macs"
88-
raise RuntimeError(err_str)
89-
9086
is_pi = thisPlatform.startswith("arm")
9187
prebuiltWheelsPythonVersion = [7,9]
9288
if requireOpenCv and is_pi and sys.version_info[1] not in prebuiltWheelsPythonVersion:

setup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
## Read description (README.md)
6464
long_description = io.open("README.md", encoding="utf-8").read()
6565

66+
## Early settings
67+
MACOS_ARM64_WHEEL_NAME_OVERRIDE = 'macosx-11.0-arm64'
68+
if sys.platform == 'darwin' and platform.machine() == 'arm64':
69+
os.environ['_PYTHON_HOST_PLATFORM'] = MACOS_ARM64_WHEEL_NAME_OVERRIDE
70+
6671
class CMakeExtension(Extension):
6772
def __init__(self, name, sourcedir=''):
6873
Extension.__init__(self, name, sources=[])
@@ -105,7 +110,7 @@ def build_extension(self, ext):
105110
# Windows - remove case insensitive variants
106111
env = {key:env[key] for key in env if key.upper() != 'pythonLocation'.upper()}
107112
env['pythonLocation'] = str(Path(sys.executable).parent.absolute())
108-
113+
109114

110115
# Pass a commit hash
111116
if buildCommitHash != None :
@@ -155,8 +160,13 @@ def build_extension(self, ext):
155160
# if macos add some additional env vars
156161
if sys.platform == 'darwin':
157162
from distutils import util
158-
env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
159-
env['_PYTHON_HOST_PLATFORM'] = re.sub(r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1', util.get_platform())
163+
if platform.machine() == 'arm64':
164+
# Build ARM64 wheels explicitly instead of universal2
165+
env['MACOSX_DEPLOYMENT_TARGET'] = '11.0'
166+
env['_PYTHON_HOST_PLATFORM'] = MACOS_ARM64_WHEEL_NAME_OVERRIDE
167+
else:
168+
env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
169+
env['_PYTHON_HOST_PLATFORM'] = re.sub(r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1', util.get_platform())
160170

161171
# Specify how many threads to use when building, depending on available memory
162172
max_threads = multiprocessing.cpu_count()

0 commit comments

Comments
 (0)