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

feat: add universal2 support #63

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- os: windows-2016
arch: "x86"
- os: macos-10.15
arch: "x86_64"
arch: "universal2"

steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 10 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# -*- coding: utf-8 -*-
import argparse
import sys
from pathlib import Path

import nox

nox.options.sessions = ["lint", "build", "tests"]

BUILD_ENV = {
"MACOSX_DEPLOYMENT_TARGET": "10.9",
}

if sys.platform.startswith("darwin"):
BUILD_ENV = {
"MACOSX_DEPLOYMENT_TARGET": "10.9",
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
"CFLAGS": "-save-temps",
"CXXFLAGS": "-save-temps",
Comment on lines +14 to +15
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why this is required when building locally but not in GHA...
It definitely fails without this on my laptop.

}
else:
BUILD_ENV = {}

built = ""

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ manylinux-i686-image = "manylinux1"

[tool.cibuildwheel.macos.environment]
MACOSX_DEPLOYMENT_TARGET = "10.9"
CMAKE_OSX_ARCHITECTURES = "arm64;x86_64"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be able to get rid of this once scikit-build 0.12 lands.


[tool.cibuildwheel.windows]
before-all = [
Expand Down
26 changes: 25 additions & 1 deletion scripts/repair_wheel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import argparse
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -43,7 +44,7 @@ def main():
subprocess.run(["auditwheel", "repair", "-w", str(tmpdir), str(file)], check=True, stdout=subprocess.PIPE)
elif os_ == "macos":
subprocess.run(
["delocate-wheel", "--require-archs", "x86_64", "-w", str(tmpdir), str(file)],
["delocate-wheel", "--require-archs", "x86_64,arm64", "-w", str(tmpdir), str(file)],
check=True,
stdout=subprocess.PIPE,
)
Expand All @@ -54,11 +55,34 @@ def main():
assert len(files) == 1, files
file = files[0]

# we need to handle macOS universal2 & arm64 here for now, let's use additional_platforms for this.
additional_platforms = []
if os_ == "macos":
# first, get the target macOS deployment target from the wheel
match = re.match(r"^.*-macosx_(\d+)_(\d+)_x86_64\.whl$", file.name)
assert match is not None
target = tuple(map(int, match.groups()))

# let's add universal2 platform for this wheel.
additional_platforms = ["macosx_{}_{}_universal2".format(*target)]

# given pip support for universal2 was added after arm64 introduction
# let's also add arm64 platform.
arm64_target = target
if arm64_target < (11, 0):
arm64_target = (11, 0)
additional_platforms.append("macosx_{}_{}_arm64".format(*arm64_target))

if target < (11, 0):
# They're were also issues with pip not picking up some universal2 wheels, tag twice
additional_platforms.append("macosx_11_0_universal2")

# make this a py2.py3 wheel
convert_to_generic_platform_wheel(
str(file),
out_dir=str(wheelhouse),
py2_py3=True,
additional_platforms=additional_platforms,
)


Expand Down