diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f6cc4099..ec316ade 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,17 +31,36 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + # setup-python Python < 3.11 doesn't support universal binaries + # https://github.com/actions/setup-python/issues/439#issuecomment-1247646682 + include: + - os: macos-latest + python-version: "3.8" + brew-python: true + - os: macos-latest + python-version: "3.9" + brew-python: true + - os: macos-latest + python-version: "3.10" + brew-python: true steps: - name: Check out repo uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} + if: "! matrix.brew-python" uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} (macOS fallback) + if: matrix.brew-python + run: | + brew install python${{matrix.python-version}} + 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 @@ -53,13 +72,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