Skip to content

Commit

Permalink
workflows: build wheels for Linux and macOS
Browse files Browse the repository at this point in the history
The convert module doesn't use any libc APIs, so we can build on any Linux
distro and auditwheel will tag the wheel as the oldest manylinux.

Signed-off-by: Benjamin Gilbert <[email protected]>
  • Loading branch information
bgilbert committed Nov 1, 2023
1 parent 40e7604 commit e79a99e
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,38 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
# Python 3.8 is too old to support universal binaries, and
# setup-python's Python 3.9 and 3.10 won't build them. Use the
# last upstream patch releases with installers.
# https://github.com/actions/setup-python/issues/439#issuecomment-1247646682
include:
- os: macos-latest
python-version: "3.9"
upstream-python: 3.9.13
- os: macos-latest
python-version: "3.10"
upstream-python: 3.10.11
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
if: matrix.upstream-python == null
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} (macOS fallback)
if: matrix.upstream-python != null
run: |
pkg="${{ runner.temp }}/python.pkg"
curl -Lo "$pkg" \
"https://www.python.org/ftp/python/${{ matrix.upstream-version }}/python-${{ matrix.upstream-version }}-macos11.pkg"
sudo installer -pkg "$pkg" -target /
python -V
pip -V
- name: Install Python tools
run: |
python -m pip install --upgrade pip
pip install build jinja2 pytest
pip install auditwheel build jinja2 pytest setuptools
- name: Install OpenSlide
run: |
case "${{ matrix.os }}" in
Expand All @@ -53,13 +74,36 @@ jobs:
;;
esac
- name: Build wheel
run: python -m build -w
run: |
python -m build -w
case "${{ matrix.os }}" in
ubuntu-*)
mv dist old
auditwheel repair --only-plat -w dist old/*whl
;;
macos-*)
if [ ! -e dist/*universal2* ]; then
echo "Wheel is not universal:"
ls dist
exit 1
fi
;;
esac
basename=openslide-python-wheels-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
mkdir -p "artifacts/${basename}"
mv dist/*.whl "artifacts/${basename}"
echo "basename=${basename}" >> $GITHUB_ENV
- name: Install
run: pip install dist/*.whl
run: pip install artifacts/${basename}/*.whl
- name: Run tests
run: pytest -v
- name: Tile slide
run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs
- name: Archive wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.basename }}
path: artifacts
windows:
name: Windows
needs: pre-commit
Expand Down

0 comments on commit e79a99e

Please sign in to comment.