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

Add changes to support building arm64 macos wheels #1383

Merged
merged 45 commits into from
Feb 14, 2024

Conversation

palonso
Copy link
Contributor

@palonso palonso commented Oct 24, 2023

In theory, Apple Silicon wheels can be cross-compiled from the intel mac machines (however the can't be tested):
https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon

Additionally, we replace os.system calls by subprocess.run so that we can notice when one of these subprocesses fail.

@@ -39,6 +39,19 @@ before-all = [
test-command = "python -c 'import essentia; import essentia.standard; import essentia.streaming; from essentia.standard import MonoLoader, MetadataReader, YamlInput, Chromaprinter, TensorflowPredict'"


[[tool.cibuildwheel.overrides]]
select = "*arm64*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the override select more specific so that it only triggers macos builds (to avoid a conflict with future arm64 Linux builds).

@dbogdanov
Copy link
Member

dbogdanov commented Oct 24, 2023

In theory, Apple Silicon wheels can be cross-compiled from the intel mac machines (however the can't be tested).

I think this won't work because we rely on homebrew to install dependencies (and those would still be x86).

@palonso
Copy link
Contributor Author

palonso commented Oct 25, 2023

In theory, Apple Silicon wheels can be cross-compiled from the intel mac machines (however the can't be tested).

I think this won't work because we rely on homebrew to install dependencies (and those would still be x86).

You are right. I was exploring this hack to force installing arm64 libs for the cross-build case.

Pablo Alonso and others added 25 commits January 31, 2024 15:42
In theory, Apple Silicon wheels can be cross-compiled from the intel mac
machines (however the can't be tested):
https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon

Additionally, we replace `os.system` calls by `subprocess.run` so that
we can notice when one of these subprocesses fail.
- Use brew reinstall instead of brew install.
- Remove incorrect brew install command.
src/3rdparty/nnls/nnls.c was not cross-built for arm64 because the
arch flag was not set for .c files.
The wheel building process should be informed of the arch we are
building for. If this operation works we should implement a mechanism to
tell setup.py when we are cross-compiling. Maybe via env variable.
according to GHs' blog, setting `runs-on` to `macos-14` automatically
provides an M2 machine.

Changes:
- discard setting `CIBW_ARCHS_MACOS: arm64` to cross-compile
- set `os` to `macos-14`. TODO: recover `macos-11` when this works.
- discard forcing arm64 brew bottles since it shoudn't be needed
  anymore.

(https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/)
@palonso palonso force-pushed the support-apple-silicon-cross-build branch from 2a937b2 to 574aefe Compare January 31, 2024 14:44
Node.js 16 actions are deprecated ->
github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
This version was previously skipped because we found errors when
building wheels locally. We accidentally missed a leading * and found
that the wheels could be created flawlessly in Actions. Restoring these
wheels for now.
cibuildwheel 2.16.5 takes care of pipx in macos-14 so that we don't have
to manually install it.

https://github.com/pypa/cibuildwheel/releases/tag/v2.16.5
@palonso
Copy link
Contributor Author

palonso commented Feb 1, 2024

After the release of the native arm64 MacOS worker (macos-14), this PR has been updated to use it directly instead of cross-compiling from an intel machine.

Main changes:

  • Add macos-14 worker for arm64 based (M*) MacOS wheels
  • Bump the Intel MacOS builds macos-11 [deprecated] -> macos-12
  • Bump Actions checkout, and upload-artifact from v3 -> v4, so they use node 20 instead of node 16 (that will reach the end of life by Spring 2024).
  • Bump cibuildwheels 11.4 -> 16.5 which internally upgrades setup-python to use node 20 instead of 16 and supports building wheels for Python 3.12.
  • Manually copy libSLD2 dylibs into macos-14 wheels to prevent crashes (Support essentia install on macOS #1325).

@palonso palonso requested a review from dbogdanov February 1, 2024 16:08
@dbogdanov
Copy link
Member

There is an error in building the arm64 essentia-tensorflow wheels for MacOS. The artifact-macos-14-pyproject-tensorflow.zip contains files for main esssentia instead (e.g., essentia-2.1b6.dev1161-cp310-cp310-macosx_11_0_arm64.whl)

pyproject-tensorflow.toml Outdated Show resolved Hide resolved
@dbogdanov dbogdanov merged commit cdc7700 into MTG:master Feb 14, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants