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.

auditwheel requires setuptools on Python 3.12 for distutils.

Fixes: openslide#126
Fixes: openslide#187
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
  • Loading branch information
bgilbert committed Nov 1, 2023
1 parent 37f6fb9 commit 4b05970
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,45 @@ 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 that ship 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: |
pkgdir="${{ runner.temp }}/python"
mkdir -p "$pkgdir/bin"
pkg="$pkgdir/python.pkg"
curl -Lfo "$pkg" \
"https://www.python.org/ftp/python/${{ matrix.upstream-python }}/python-${{ matrix.upstream-python }}-macos11.pkg"
sudo installer -pkg "$pkg" -target /
for bin in python pip; do
ln -s /usr/local/bin/${bin}3 $pkgdir/bin/${bin}
done
export PATH="$pkgdir/bin:$PATH"
echo "PATH=$PATH" >> $GITHUB_ENV
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 +81,36 @@ jobs:
;;
esac
- name: Build wheel
run: python -m build -w
run: |
python -m build -w
case "${{ matrix.os }}" in
ubuntu-*)
mkdir old
mv dist/*.whl old/
auditwheel repair --only-plat -w dist old/*whl
;;
macos-*)
if [ "${{ matrix.python-version }}" != 3.8 -a ! -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/* "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 4b05970

Please sign in to comment.