Skip to content

Commit

Permalink
gha/macos-wheels: Build wheels for arm64 architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Nov 26, 2024
1 parent d20c52b commit d219d9a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/macos-macports-wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ name: macos-macports-wheels-build
on: [push, pull_request]
jobs:
macos:
name: Talipot Python wheels build on macOS
runs-on: macos-12
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: Talipot wheels build on macOS x86_64
os: macos-12
- name: Talipot wheels build on macOS arm64
os: macos-14
env:
CLANG_VERSION: 16
MACOSX_DEPLOYMENT_TARGET: "12.0"
TWINE_REPOSITORY: https://test.pypi.org/legacy/
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand Down Expand Up @@ -77,9 +86,12 @@ jobs:
graphviz
- name: Install Python versions to build wheels against
run: |
curl -LO https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg
sudo installer -pkg python-3.9.0-macosx10.9.pkg -target /
sudo /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3 install wheel
os_ver=$(sw_vers -productVersion | cut -c1-2)
if [[ $os_ver -lt 13 ]]; then
curl -LO https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg
sudo installer -pkg python-3.9.0-macosx10.9.pkg -target /
sudo /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3 install wheel
fi
curl -LO https://www.python.org/ftp/python/3.10.0/python-3.10.0post2-macos11.pkg
sudo installer -pkg python-3.10.0post2-macos11.pkg -target /
sudo /Library/Frameworks/Python.framework/Versions/3.10/bin/pip3 install wheel
Expand All @@ -97,7 +109,13 @@ jobs:
- name: Build Talipot Python wheels
working-directory: ./build
run: |
for py3Version in 3.9 3.10 3.11 3.12 3.13
os_ver=$(sw_vers -productVersion | cut -c1-2)
if [[ $os_ver -lt 13 ]]; then
py3Versions="3.9 3.10 3.11 3.12 3.13"
else
py3Versions="3.10 3.11 3.12 3.13"
fi
for py3Version in $py3Versions
do
rm -f CMakeCache.txt || true
sudo /Library/Frameworks/Python.framework/Versions/$py3Version/bin/pip3 install sip
Expand All @@ -120,6 +138,7 @@ jobs:
- name: Test uploaded wheels in clean environment
if: github.ref == 'refs/tags/dev-latest'
run: |
os_ver=$(sw_vers -productVersion | cut -c1-2)
sudo port -N -f uninstall \
cmake \
clang-${CLANG_VERSION} \
Expand All @@ -140,9 +159,11 @@ jobs:
python313 \
py313-pip
sudo pip-3.9 install --index-url https://test.pypi.org/simple/ talipot
python3.9 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())"
python3.9 -c "from talipot import tlp; print(tlp.getImportPluginsList())"
if [[ $os_ver -lt 13 ]]; then
sudo pip-3.9 install --index-url https://test.pypi.org/simple/ talipot
python3.9 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())"
python3.9 -c "from talipot import tlp; print(tlp.getImportPluginsList())"
fi
sudo pip-3.10 install --index-url https://test.pypi.org/simple/ talipot
python3.10 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())"
Expand Down
15 changes: 15 additions & 0 deletions library/talipot-python/bindings/talipot-core/packaging/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import subprocess
import sys
import shutil

from wheel.bdist_wheel import bdist_wheel
from wheel._bdist_wheel get_platform

# On MacOS, we need to relink dylibs and set correct rpaths in
# order for the modules to be imported in a portable way when
# distributed through pip
Expand Down Expand Up @@ -111,6 +114,17 @@ elif platform.system() == 'Linux':
talipot_native_libs = ['native/*.so*', 'native/plugins/*.so',
'native/graphviz/*.so']


class CustomWheel(bdist_wheel):
"""Override platform tags when building a wheel."""

def finalize_options(self):
platform_name = get_platform("_")
if "universal2" in platform_name:
self.plat_name = platform_name.replace("universal2", platform.uname().machine)



here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
Expand Down Expand Up @@ -183,4 +197,5 @@ setup(

include_package_data=True,
distclass=BinaryDistribution,
cmdclass={"bdist_wheel": CustomWheel},
)

0 comments on commit d219d9a

Please sign in to comment.