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

Universal2 wheels on macOS #484

Merged
merged 66 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
90ce9d9
Update dependencies and macOS 11 CI on Github
joerick Dec 16, 2020
59801d4
Disable macOS CPython 3.5 build for now
joerick Dec 16, 2020
609c0f3
WIP: try new Python build
henryiii Dec 17, 2020
7fb032d
Try using _PYTHON_HOST_PLATFORM to create single-arch builds
joerick Dec 18, 2020
9906cf7
Fix logger crash
joerick Dec 18, 2020
985ef4d
wip: drop pypy for now
henryiii Dec 18, 2020
31d0351
Upload some sample wheels as artifacts
joerick Dec 28, 2020
2e8e806
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Dec 28, 2020
2b800bb
Build some sample wheels
joerick Dec 31, 2020
76d5f3d
Call delocate with the correct archs
joerick Dec 31, 2020
4d89e52
Add rename hack to make the universal wheel work on both archs
joerick Jan 1, 2021
09fef56
Make tests expect arm64 and universal2
joerick Jan 1, 2021
8d04599
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 1, 2021
7cab712
Fix unit test
joerick Jan 2, 2021
a1ac43e
Override buildable archs on macOS 11
joerick Jan 5, 2021
a973ba9
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 5, 2021
46eb287
Refactor for clarity
joerick Jan 5, 2021
e405f34
Print warnings when builds are deselected because of build OS
joerick Jan 5, 2021
df60457
Use the ARCHS option to select universal2/arm64 builds
joerick Jan 5, 2021
577fd5e
Implement testing for universal2/arm64 wheels
joerick Jan 5, 2021
914f74a
Interim fix for archs comparison
joerick Jan 5, 2021
afd08c1
Maybe Azure secretly supports macOS 11.0?
joerick Jan 5, 2021
7a11143
Like this?
joerick Jan 5, 2021
16d96fa
It does not.
joerick Jan 5, 2021
65b530a
On arm64, build native before cross-compile
joerick Jan 5, 2021
121715a
Skip cross-compile test on macOS <11
joerick Jan 5, 2021
bf272fe
Use same interpreter for sample_build.py (for local testing of arm64)
joerick Jan 5, 2021
a6ff55e
Update pip in the test virtualenv
joerick Jan 5, 2021
e215446
Increase test timeout value
joerick Jan 5, 2021
0df5e12
Only print testing warnings if test command is set
joerick Jan 5, 2021
ffba89d
Improve output formatting
joerick Jan 5, 2021
e29fab0
Add test for cross-compile testing behaviour
joerick Jan 5, 2021
e880aca
Tidy up
joerick Jan 6, 2021
9bf5fb1
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 6, 2021
0768123
Fix allowed archs check
joerick Jan 6, 2021
1606b79
Fix macOS Big Sur version checks
joerick Jan 8, 2021
c4b5b16
Add clarifying comments
joerick Jan 8, 2021
f43b3f5
Fix warning lines counting as build identifiers in test
joerick Jan 8, 2021
8512e69
Improve expected_wheels correctness
joerick Jan 8, 2021
9113dfe
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 8, 2021
a99726f
Neaten comments
joerick Jan 8, 2021
dbb6d80
Route warnings and error messages to stderr, not stdout.
joerick Jan 8, 2021
af8ab0a
Update test to look in stderr for warnings
joerick Jan 9, 2021
e83b770
Add back other platforms to GHA CI
joerick Jan 9, 2021
d2312cd
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 23, 2021
3f8fcb0
Fix unit tests
joerick Jan 23, 2021
bd45b1c
Remove pinned pip install, virtualenv should bundle this now
joerick Jan 24, 2021
00eed5a
Fix crashing test
joerick Jan 24, 2021
4dddd9e
Silence the pip version warnings
joerick Jan 24, 2021
381ea7d
Add docs for CIBW_ARCHS
joerick Jan 24, 2021
4b491ce
Docs edits
joerick Jan 24, 2021
ef1baac
Indent subheads in TOC on all pages
joerick Jan 24, 2021
8c68e48
Add FAQ entry explaining Apple Silicon support
joerick Jan 24, 2021
f1638e7
The macos-10.15 image contains Xcode 12, which should be sufficient..…
joerick Jan 24, 2021
e40d53d
Add manual debugging hook
joerick Jan 24, 2021
d21b7cf
Add SDKROOT setting for building arm64, universal2 on 10.15
joerick Jan 24, 2021
b6f325c
Implement CIBW_TEST_SKIP for individual archs of a universal2 wheel
joerick Jan 26, 2021
93ba19d
Make the sample build do some cross compile for manual testing
joerick Jan 26, 2021
c8fde72
Select the correct macos 11 SDK for the version of xcode available
joerick Jan 26, 2021
4ff52ae
Add ARCHFLAGS workaround for building universal2 on macOS 10.15
joerick Jan 29, 2021
32ab09b
Tidy up and correct a few things
joerick Jan 30, 2021
56653f3
Fix typing import
joerick Jan 30, 2021
74170ba
Get SDK version dynamically
joerick Jan 30, 2021
be55ebe
Merge remote-tracking branch 'origin/master' into macos-universal2
joerick Jan 30, 2021
a79f0ef
Remove wheel rename hack
joerick Jan 30, 2021
2def20d
Remove unused function
joerick Jan 30, 2021
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
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ jobs:
run: |
python bin/sample_build.py

- name: Get some sample wheels
run: |
python -m test.test_projects test.test_0_basic.basic_project sample_proj
cibuildwheel --output-dir wheelhouse sample_proj
env:
CIBW_ARCHS_MACOS: x86_64 universal2 arm64

- uses: actions/upload-artifact@v2
henryiii marked this conversation as resolved.
Show resolved Hide resolved
with:
name: sample_wheels
path: wheelhouse

- name: Test cibuildwheel
run: |
python ./bin/run_tests.py
Expand Down
2 changes: 1 addition & 1 deletion bin/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
subprocess.check_call(unit_test_args)

# run the integration tests
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', '--timeout=1200', 'test'])
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', '--timeout=2400', 'test'])
2 changes: 1 addition & 1 deletion bin/sample_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
options.project_python_path, project_dir
], check=True)

sys.exit(subprocess.run(['cibuildwheel'], cwd=project_dir).returncode)
sys.exit(subprocess.run([sys.executable, '-m', 'cibuildwheel'], cwd=project_dir).returncode)
4 changes: 2 additions & 2 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def main() -> None:
if platform == 'linux':
repair_command_default = 'auditwheel repair -w {dest_dir} {wheel}'
elif platform == 'macos':
repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'
repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}'
elif platform == 'windows':
repair_command_default = ''
else:
Expand Down Expand Up @@ -339,7 +339,7 @@ def get_build_identifiers(
elif platform == 'windows':
python_configurations = cibuildwheel.windows.get_python_configurations(build_selector, architectures)
elif platform == 'macos':
python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)
python_configurations = cibuildwheel.macos.get_python_configurations(build_selector, architectures)
henryiii marked this conversation as resolved.
Show resolved Hide resolved
else:
assert_never(platform)

Expand Down
15 changes: 14 additions & 1 deletion cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ class Architecture(Enum):

# mac/linux archs
x86_64 = 'x86_64'

# linux archs
i686 = 'i686'
aarch64 = 'aarch64'
ppc64le = 'ppc64le'
s390x = 's390x'

# mac archs
universal2 = 'universal2'
arm64 = 'arm64'

# windows archs
x86 = 'x86'
AMD64 = 'AMD64'
Expand All @@ -46,19 +52,26 @@ def parse_config(config: str, platform: PlatformName) -> 'Set[Architecture]':
def auto_archs(platform: PlatformName) -> 'Set[Architecture]':
native_architecture = Architecture(platform_module.machine())
result = {native_architecture}

if platform == 'linux' and native_architecture == Architecture.x86_64:
# x86_64 machines can run i686 docker containers
result.add(Architecture.i686)

if platform == 'windows' and native_architecture == Architecture.AMD64:
result.add(Architecture.x86)

if platform == 'macos' and native_architecture == Architecture.arm64:
# arm64 can build and test both archs of a universal2 wheel.
mayeut marked this conversation as resolved.
Show resolved Hide resolved
result.add(Architecture.universal2)

return result

@staticmethod
def all_archs(platform: PlatformName) -> 'Set[Architecture]':
if platform == 'linux':
return {Architecture.x86_64, Architecture.i686, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x}
elif platform == 'macos':
return {Architecture.x86_64}
return {Architecture.x86_64, Architecture.arm64, Architecture.universal2}
joerick marked this conversation as resolved.
Show resolved Hide resolved
elif platform == 'windows':
return {Architecture.x86, Architecture.AMD64}
else:
Expand Down
3 changes: 2 additions & 1 deletion cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def build(options: BuildOptions) -> None:

env = docker.get_environment()
env['PATH'] = f'/opt/python/cp38-cp38/bin:{env["PATH"]}'
env['PIP_DISABLE_PIP_VERSION_CHECK'] = '1'
env = options.environment.as_dictionary(env, executor=docker.environment_executor)

before_all_prepared = prepare_command(options.before_all, project=container_project_path, package=container_package_dir)
Expand Down Expand Up @@ -228,7 +229,7 @@ def build(options: BuildOptions) -> None:
docker.copy_out(container_output_dir, options.output_dir)
log.step_end()
except subprocess.CalledProcessError as error:
log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
log.step_end_with_error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
troubleshoot(options.package_dir, error)
sys.exit(1)

Expand Down
18 changes: 14 additions & 4 deletions cibuildwheel/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'win32': 'Windows 32bit',
'win_amd64': 'Windows 64bit',
'macosx_x86_64': 'macOS x86_64',
'macosx_universal2': 'macOS Universal 2 - x86_64 and arm64',
'macosx_arm64': 'macOS arm64 - Apple Silicon',
}


Expand Down Expand Up @@ -109,15 +111,23 @@ def step_end(self, success: bool = True) -> None:

self.step_start_time = None

def error(self, error: Union[BaseException, str]) -> None:
def step_end_with_error(self, error: Union[BaseException, str]) -> None:
self.step_end(success=False)
print()
self.error(error)

def warning(self, message: str) -> None:
if self.fold_mode == 'github':
print(f'::warning::{message}\n', file=sys.stderr)
else:
c = self.colors
print(f'{c.yellow}Warning{c.end}: {message}\n', file=sys.stderr)

def error(self, error: Union[BaseException, str]) -> None:
if self.fold_mode == 'github':
print(f'::error::{error}')
print(f'::error::{error}\n', file=sys.stderr)
else:
c = self.colors
print(f'{c.bright_red}Error{c.end} {error}')
print(f'{c.bright_red}Error{c.end}: {error}\n', file=sys.stderr)

def _start_fold_group(self, name: str) -> None:
self._end_fold_group()
Expand Down