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

Enable building x86_64, arm64 and universal2 wheels on supported macOS Python versions #173

Merged
merged 8 commits into from
Nov 16, 2022

Conversation

dataflake
Copy link
Member

This change applies the same environment flags used by cibuildwheel. Specifically, version 10.9 is explicitly selected when building x86_64 (and universal2) wheels. Only arm64 wheels select version 11.0. See here for details:

https://github.com/pypa/cibuildwheel/blob/2e6cbe2435ef410156319c98625002ed76e08785/cibuildwheel/macos.py#L217-L232

I have tried it on AccessControl master and the wheels get built just fine, see https://github.com/zopefoundation/AccessControl/actions/runs/3445282682/jobs/5748817908

You don't happen to know how to get the equivalent of "python version > 3.10" into a GHA expression, do you? That list of specific versions as condition irks me.

@dataflake dataflake requested a review from icemac November 11, 2022 13:35
@dataflake dataflake changed the title Use same build flags as cibuildwheel Build with same build flags as cibuildwheel Nov 11, 2022
@dataflake
Copy link
Member Author

The first cut still failed during BTrees build on macOS/Python 3.11 as setuptools still got the persistent wheel a second time.

I have added a new flag to specify additional packages to install during the Install Build Dependencies step. Installing the dependency (in the case of BTrees it's persistent) at that point will make sure that setuptools knows the egg is already there. It will use that pre-installed egg both for the setup_requires and the install_requires phase of the setup procedure.

@dataflake dataflake self-assigned this Nov 11, 2022
@dataflake
Copy link
Member Author

dataflake commented Nov 12, 2022

I have now added building x86_64 and arm64 wheels on macOS with Python versions >= 3.8. Python 3.8 is the first version that supports Apple's M-class chips.

arm64 wheels cannot be tested on the GHA runners. So only the x86_64 wheel gets the default name XXX-${{ runner.os }}-${{ matrix.python-version }}.whl and is then picked up by the test step. The arm64 wheel is uploaded as separate artifact so it can be downloaded when desired.

@dataflake
Copy link
Member Author

The first test run of this new configuration is with the BTrees package, see https://github.com/zopefoundation/BTrees/actions/runs/3450155539.

@dataflake dataflake changed the title Build with same build flags as cibuildwheel Enable building both x86_64 and arm64 wheels on supported macOS Python versions Nov 13, 2022
@dataflake dataflake changed the title Enable building both x86_64 and arm64 wheels on supported macOS Python versions Enable building x86_64, arm64 and universal2 wheels on supported macOS Python versions Nov 15, 2022
@dataflake
Copy link
Member Author

I will merge this tomorrow morning if there's no feedback. I'm traveling later this week and would like to get this done.

Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

The direction seems good, though I can't follow all the details.

I wonder if it would help for relevant packages to use PEP 517 to specify the build system, and then use the build tool to create sdist and wheels. But I did not try any of this, I have only heard of it.

Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

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

Thank you for putting so much effort into this issue.

|| startsWith(matrix.python-version, '3.11'))
&& !(startsWith(matrix.python-version, 'pypy')
|| matrix.python-version == '2.7'
|| matrix.python-version == '3.5'
Copy link
Member

Choose a reason for hiding this comment

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

This looks okay as this list will shrink when we stop supporting Python < 3.6. (Maybe we could even think about dropping Python 3.6 support.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to make sure it's a list that doesn't need growing as new Python versions are releases. I'm still unhappy that there's apparently no way to safely express something like matrix.python-version < '3.8', something that understands versioning.

- name: Install %(package_name)s and dependencies (%(future_python_version)s)
if: matrix.python-version == '%(future_python_version)s'
run: |
# Install to collect dependencies into the (pip) cache.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the comment could contain a hint about the --pre flag.
We added it to build AccessControl against Python 3.11beta-X because a dev version of RestrictedPython was needed as its released version was not even installable on Python 3.11.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, comment added.

@dataflake
Copy link
Member Author

I wonder if it would help for relevant packages to use PEP 517 to specify the build system, and then use the build tool to create sdist and wheels. But I did not try any of this, I have only heard of it.

I think anything is better than the current situation where we have a mix of packages that either contain copies of header files from other packages (which may drift apart) or that use convoluted code to install requirements and then locate the path to the header files inside the packages. But that's for another day...

@dataflake dataflake merged commit 342271a into master Nov 16, 2022
@dataflake dataflake deleted the fix-macos-build branch November 16, 2022 08:12
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.

3 participants