@@ -31,17 +31,48 @@ jobs:
3131 matrix :
3232 os : [ubuntu-latest, macos-latest]
3333 python-version : [3.8, 3.9, "3.10", "3.11", "3.12"]
34+ include :
35+ - os : ubuntu-latest
36+ python-version : " 3.12"
37+ sdist : sdist
38+ # Python 3.8 is too old to support universal binaries, and
39+ # setup-python's Python 3.9 and 3.10 won't build them. Use the
40+ # last upstream patch releases that ship with installers.
41+ # https://github.com/actions/setup-python/issues/439#issuecomment-1247646682
42+ - os : macos-latest
43+ python-version : " 3.9"
44+ upstream-python : 3.9.13
45+ - os : macos-latest
46+ python-version : " 3.10"
47+ upstream-python : 3.10.11
3448 steps :
3549 - name : Check out repo
3650 uses : actions/checkout@v4
3751 - name : Set up Python ${{ matrix.python-version }}
52+ if : matrix.upstream-python == null
3853 uses : actions/setup-python@v4
3954 with :
4055 python-version : ${{ matrix.python-version }}
56+ - name : Set up Python ${{ matrix.python-version }} (macOS fallback)
57+ if : matrix.upstream-python != null
58+ run : |
59+ pkgdir="${{ runner.temp }}/python"
60+ mkdir -p "$pkgdir/bin"
61+ pkg="$pkgdir/python.pkg"
62+ curl -Lfo "$pkg" \
63+ "https://www.python.org/ftp/python/${{ matrix.upstream-python }}/python-${{ matrix.upstream-python }}-macos11.pkg"
64+ sudo installer -pkg "$pkg" -target /
65+ for bin in python pip; do
66+ ln -s /usr/local/bin/${bin}3 $pkgdir/bin/${bin}
67+ done
68+ export PATH="$pkgdir/bin:$PATH"
69+ echo "PATH=$PATH" >> $GITHUB_ENV
70+ python -V
71+ pip -V
4172 - name : Install Python tools
4273 run : |
4374 python -m pip install --upgrade pip
44- pip install jinja2 pytest setuptools
75+ pip install auditwheel build jinja2 pytest setuptools
4576 - name : Install OpenSlide
4677 run : |
4778 case "${{ matrix.os }}" in
@@ -52,12 +83,40 @@ jobs:
5283 brew install openslide
5384 ;;
5485 esac
86+ - name : Build wheel
87+ run : |
88+ if [ -z "${{ matrix.sdist }}" ]; then
89+ wheel_only=-w
90+ fi
91+ python -m build $wheel_only
92+ case "${{ matrix.os }}" in
93+ ubuntu-*)
94+ mkdir old
95+ mv dist/*.whl old/
96+ auditwheel repair --only-plat -w dist old/*whl
97+ ;;
98+ macos-*)
99+ if [ "${{ matrix.python-version }}" != 3.8 -a ! -e dist/*universal2* ]; then
100+ echo "Wheel is not universal:"
101+ ls dist
102+ exit 1
103+ fi
104+ esac
105+ basename=openslide-python-wheels-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
106+ mkdir -p "artifacts/${basename}"
107+ mv dist/* "artifacts/${basename}"
108+ echo "basename=${basename}" >> $GITHUB_ENV
55109 - name : Install
56- run : pip install .
110+ run : pip install artifacts/${basename}/*.whl
57111 - name : Run tests
58112 run : pytest -v
59113 - name : Tile slide
60114 run : python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs
115+ - name : Archive wheel
116+ uses : actions/upload-artifact@v3
117+ with :
118+ name : ${{ env.basename }}
119+ path : artifacts
61120 windows :
62121 name : Windows
63122 needs : pre-commit
@@ -80,24 +139,24 @@ jobs:
80139 - name : Install Python tools
81140 run : |
82141 python -m pip install --upgrade pip
83- pip install flask Pillow pytest setuptools wheel
142+ pip install build flask pytest
84143 - name : Install OpenSlide
85144 run : |
86145 mkdir -p c:\\openslide
87146 cd c:\\openslide
88147 zipname=openslide-win64-${BIN_RELEASE}
89- curl -LO "https://github.com/openslide/openslide-bin/releases/download/v${BIN_RELEASE}/${zipname}.zip"
148+ curl -LfO "https://github.com/openslide/openslide-bin/releases/download/v${BIN_RELEASE}/${zipname}.zip"
90149 7z x ${zipname}.zip
91150 echo "OPENSLIDE_PATH=c:\\openslide\\${zipname}\\bin" >> $GITHUB_ENV
92151 - name : Build wheel
93152 run : |
94- python setup.py bdist_wheel
153+ python -m build -w
95154 basename=openslide-python-wheels-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
96155 mkdir -p "artifacts/${basename}"
97156 mv dist/*.whl "artifacts/${basename}"
98157 echo "basename=${basename}" >> $GITHUB_ENV
99158 - name : Install
100- run : pip install -e .
159+ run : pip install artifacts/${basename}/*.whl
101160 - name : Run tests
102161 # Reads OPENSLIDE_PATH
103162 run : pytest -v
0 commit comments