Skip to content

Commit

Permalink
actions: add Apple M support
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
  • Loading branch information
noxdafox committed Feb 17, 2024
1 parent 6d10327 commit c5543fb
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
45 changes: 42 additions & 3 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
name: windows-build
path: dist/

build-macos:
runs-on: macos-latest
build-macos-intel:
runs-on: macos-12
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
Expand Down Expand Up @@ -88,5 +88,44 @@ jobs:
- name: Store build artifacts
uses: actions/upload-artifact@v3
with:
name: macos-build
name: macos-intel-build
path: dist/

build-macos-arm:
runs-on: macos-14
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade cffi wheel delocate pytest setuptools
- name: Build and install CLIPS
run: |
sudo make install-clips
- name: Build CLIPSPy
run: |
sudo python setup.py build_ext --plat-name=macosx-14.0-arm64 --include-dirs=clips_source/ --library-dirs=clips_source/
sudo python setup.py sdist bdist_wheel --plat-name=macosx-14.0-arm64
- name: Repair wheels
run: |
sudo ./repair_wheels_osx.sh
- name: Install CLIPSPy
run: |
pip install dist/*.whl
- name: Run tests
run: |
# Run test from outside module to test installed package
cd ../
python -m pytest -v clipspy/test
- name: Store build artifacts
uses: actions/upload-artifact@v3
with:
name: macos-arm-build
path: dist/
26 changes: 26 additions & 0 deletions repair_wheels_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -xe

py_platform=$(python -c "import sysconfig; print('%s' % sysconfig.get_platform());")

echo " - Python platform: ${py_platform}"
if [[ "${py_platform}" == *"-universal2" ]]; then
if [[ `uname -m` == 'arm64' ]]; then
export _PYTHON_HOST_PLATFORM="${py_platform/universal2/arm64}"
echo " - Python installation is universal2 and we are on arm64, setting _PYTHON_HOST_PLATFORM to: ${_PYTHON_HOST_PLATFORM}"
export ARCHFLAGS="-arch arm64"
echo " - Setting ARCHFLAGS to: ${ARCHFLAGS}"
# This is a shortcut to have a successful delocate-wheel. See:
# https://github.com/matthew-brett/delocate/issues/153
python -c "import os,delocate; print(os.path.join(os.path.dirname(delocate.__file__), 'tools.py'));quit()" | xargs -I{} sed -i."" "s/first, /input.pop('i386',None); first, /g" {}
else
export _PYTHON_HOST_PLATFORM="${py_platform/universal2/x86_64}"
echo " - Python installation is universal2 and we are on x84_64, setting _PYTHON_HOST_PLATFORM to: ${_PYTHON_HOST_PLATFORM}"
export ARCHFLAGS="-arch x86_64"
echo " - Setting ARCHFLAGS to: ${ARCHFLAGS}"
fi
fi

for whl in $(ls dist | grep .whl); do
delocate-wheel -v "dist/$whl" --require-archs=arm64
done

0 comments on commit c5543fb

Please sign in to comment.