-
Notifications
You must be signed in to change notification settings - Fork 6
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
Changes from all commits
f9d8613
fd8574b
2c296e2
a6a0b3d
57e4030
0a9ef01
1682092
0a0edec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,11 @@ jobs: | |
run: | | ||
pip install -U pip | ||
pip install -U setuptools wheel twine "cffi != 1.15.1" | ||
{% if gha_additional_build_dependencies %} | ||
{% for line in gha_additional_build_dependencies %} | ||
pip install -U %(line)s | ||
{% endfor %} | ||
{% endif %} | ||
- name: Install Build Dependencies (other Python versions) | ||
if: > | ||
!startsWith(matrix.python-version, 'pypy-2.7') | ||
|
@@ -112,52 +117,130 @@ jobs: | |
run: | | ||
pip install -U pip | ||
pip install -U setuptools wheel twine cffi | ||
|
||
{% if with_future_python %} | ||
- name: Build %(package_name)s (%(future_python_version)s) | ||
if: ${{ startsWith(matrix.python-version, '%(future_python_version)s') }} | ||
run: | | ||
# Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure | ||
# output (pip install uses a random temporary directory, making this difficult). | ||
python setup.py build_ext -i | ||
python setup.py bdist_wheel | ||
# Also install it, so that we get dependencies in the (pip) cache. | ||
pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' | ||
pip install --pre .[test] | ||
{% if gha_additional_build_dependencies %} | ||
{% for line in gha_additional_build_dependencies %} | ||
pip install -U %(line)s | ||
{% endfor %} | ||
{% endif %} | ||
{% for kind in ('Python 3.10 and 3.11 on MacOS', 'all other versions') %} | ||
|
||
{% for kind in ('macOS x86_64, Python 3.8+', | ||
'macOS arm64, Python 3.8+', | ||
'macOS universal2, Python 3.8+', | ||
'all other versions') %} | ||
- name: Build %(package_name)s (%(kind)s) | ||
if: > | ||
{% if kind == 'Python 3.10 and 3.11 on MacOS' %} | ||
{% if kind == 'macOS x86_64, Python 3.8+' %} | ||
startsWith(runner.os, 'Mac') | ||
&& (startsWith(matrix.python-version, '3.10') | ||
|| startsWith(matrix.python-version, '3.11')) | ||
&& !(startsWith(matrix.python-version, 'pypy') | ||
|| matrix.python-version == '2.7' | ||
|| matrix.python-version == '3.5' | ||
|| matrix.python-version == '3.6' | ||
|| matrix.python-version == '3.7') | ||
env: | ||
_PYTHON_HOST_PLATFORM: macosx-11-x86_64 | ||
MACOSX_DEPLOYMENT_TARGET: 10.9 | ||
_PYTHON_HOST_PLATFORM: macosx-10.9-x86_64 | ||
ARCHFLAGS: -arch x86_64 | ||
{% elif kind == 'macOS arm64, Python 3.8+' %} | ||
startsWith(runner.os, 'Mac') | ||
&& !(startsWith(matrix.python-version, 'pypy') | ||
|| matrix.python-version == '2.7' | ||
|| matrix.python-version == '3.5' | ||
|| matrix.python-version == '3.6' | ||
|| matrix.python-version == '3.7') | ||
env: | ||
MACOSX_DEPLOYMENT_TARGET: 11.0 | ||
_PYTHON_HOST_PLATFORM: macosx-11.0-arm64 | ||
ARCHFLAGS: -arch arm64 | ||
{% elif kind == 'macOS universal2, Python 3.8+' %} | ||
startsWith(runner.os, 'Mac') | ||
&& !(startsWith(matrix.python-version, 'pypy') | ||
|| matrix.python-version == '2.7' | ||
|| matrix.python-version == '3.5' | ||
|| matrix.python-version == '3.6' | ||
|| matrix.python-version == '3.7') | ||
env: | ||
MACOSX_DEPLOYMENT_TARGET: 10.9 | ||
_PYTHON_HOST_PLATFORM: macosx-10.9-universal2 | ||
ARCHFLAGS: -arch arm64 -arch x86_64 | ||
{% else %} | ||
!startsWith(runner.os, 'Mac') | ||
|| !(startsWith(matrix.python-version, '3.10') | ||
|| startsWith(matrix.python-version, '3.11')) | ||
|| startsWith(matrix.python-version, 'pypy') | ||
|| matrix.python-version == '2.7' | ||
|| matrix.python-version == '3.5' | ||
|| matrix.python-version == '3.6' | ||
|| matrix.python-version == '3.7' | ||
{% endif %} | ||
run: | | ||
# Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure | ||
# output (pip install uses a random temporary directory, making this difficult). | ||
python setup.py build_ext -i | ||
python setup.py bdist_wheel | ||
# Also install it, so that we get dependencies in the (pip) cache. | ||
{% endfor %} | ||
|
||
{% if with_future_python %} | ||
- 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the comment could contain a hint about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, comment added. |
||
# Use "--pre" here because dependencies with support for this future | ||
# Python release may only be available as pre-releases | ||
pip install --pre .[test] | ||
{% endif %} | ||
- name: Install %(package_name)s and dependencies | ||
{% if with_future_python %} | ||
if: matrix.python-version != '%(future_python_version)s' | ||
{% endif %} | ||
run: | | ||
# Install to collect dependencies into the (pip) cache. | ||
pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' | ||
pip install .[test] | ||
|
||
{% endfor %} | ||
- name: Check %(package_name)s build | ||
run: | | ||
ls -l dist | ||
twine check dist/* | ||
- name: Upload %(package_name)s wheel | ||
{% for kind in ('macOS x86_64', | ||
'macOS arm64', | ||
'macOS universal2', | ||
'all other platforms') %} | ||
- name: Upload %(package_name)s wheel (%(kind)s) | ||
if: > | ||
{% if kind == 'macOS x86_64' %} | ||
startsWith(runner.os, 'Mac') | ||
{% elif kind == 'macOS arm64' or kind == 'macOS universal2' %} | ||
startsWith(runner.os, 'Mac') | ||
&& !(startsWith(matrix.python-version, 'pypy') | ||
|| matrix.python-version == '2.7' | ||
|| matrix.python-version == '3.5' | ||
|| matrix.python-version == '3.6' | ||
|| matrix.python-version == '3.7') | ||
{% else %} | ||
!startsWith(runner.os, 'Mac') | ||
{% endif %} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
{% if kind == 'macOS arm64' %} | ||
# The arm64 wheel is uploaded with a different name just so it can be | ||
# manually downloaded when desired. The wheel itself *cannot* be tested | ||
# on the GHA runner, which uses x86_64 architecture. | ||
name: %(package_name)s-${{ runner.os }}-${{ matrix.python-version }}-arm64.whl | ||
{% elif kind == 'macOS universal2' %} | ||
# The universal2 wheel is uploaded with a different name just so it | ||
# can be manually downloaded when desired. | ||
name: %(package_name)s-${{ runner.os }}-${{ matrix.python-version }}-universal2.whl | ||
{% else %} | ||
name: %(package_name)s-${{ runner.os }}-${{ matrix.python-version }}.whl | ||
{% endif %} | ||
{% if kind == 'macOS x86_64' %} | ||
path: dist/*x86_64.whl | ||
{% elif kind == 'macOS arm64' %} | ||
path: dist/*arm64.whl | ||
{% elif kind == 'macOS universal2' %} | ||
path: dist/*universal2.whl | ||
{% else %} | ||
path: dist/*whl | ||
{% endif %} | ||
{% endfor %} | ||
- name: Publish package to PyPI (mac) | ||
# We cannot 'uses: pypa/[email protected]' because | ||
# that's apparently a container action, and those don't run on | ||
|
@@ -201,6 +284,8 @@ jobs: | |
# when we ask it to load tests from that directory. This | ||
# might also save some build time? | ||
unzip -n dist/%(package_name)s-*whl -d src | ||
# Use "--pre" here because dependencies with support for this future | ||
# Python release may only be available as pre-releases | ||
pip install --pre -U -e .[test] | ||
{% endif %} | ||
- name: Install %(package_name)s | ||
|
@@ -211,6 +296,7 @@ jobs: | |
pip install -U wheel setuptools | ||
pip install -U coverage | ||
pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' | ||
pip install -U 'cffi; platform_python_implementation == "CPython"' | ||
# Unzip into src/ so that testrunner can find the .so files | ||
# when we ask it to load tests from that directory. This | ||
# might also save some build time? | ||
|
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.