Skip to content

Commit

Permalink
MNT: Create and test universal wheels (#17)
Browse files Browse the repository at this point in the history
* CI: Rework build process to create one wheel and test across OSs

* MNT: Remove build-time dependency on numpy, drop beta runtime dependency

* CI: Add token to allow packages to upload

* MNT: Drop cibuildhweel config

* chore(ci): Install Python 2 on Intel MacOS runners

* Update .github/workflows/test.yml

* Update .github/workflows/test.yml

* Update .github/workflows/test.yml
  • Loading branch information
effigies authored Dec 23, 2024
1 parent ff082ef commit 76f1fd0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 167 deletions.
89 changes: 87 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test suite
name: Build, test, deploy

on:
push:
Expand All @@ -18,9 +18,9 @@ defaults:
run:
shell: bash -el {0}

# Commented sections to be uncommented once CI is active
jobs:
test:
name: Test repo install
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -68,3 +68,88 @@ jobs:
- name: Test
run: pytest --pyargs gradunwarp --cov gradunwarp
working-directory: /tmp

build:
name: Build packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build sdist and wheel
run: pipx run build
- name: Check packages
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist/*

test-dist:
name: Test package install
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-13', 'macos-latest', 'windows-latest']
python:
- ['conda', '2.7']
- ['native', '3']
package: ['sdist', 'wheel']
exclude:
# macos-latest is now exclusively aarch64, and there's no Python 2 package
- os: macos-latest
python: ['conda', '2.7']

steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: ./dist

- name: Set up Python ${{ matrix.python[1] }} (native)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python[1] }}
allow-prereleases: true
if: matrix.python[0] == 'native'
- name: Set up Python ${{ matrix.python[1] }} (miniconda)
uses: conda-incubator/setup-miniconda@v2
with:
# OSX runners do not have a built-in conda, so install, but don't change other OSs from default
miniforge-version: ${{ startsWith(matrix.os, 'macos') && 'latest' || '' }}
python-version: ${{ matrix.python[1] }}
if: matrix.python[0] == 'conda'

- name: Install sdist
run: pip install dist/*.tar.gz
if: matrix.package == 'sdist'
- name: Install wheel
run: pip install dist/*.whl
if: matrix.package == 'wheel'

- name: Check gradunwarp version
shell: bash -el -c python {0}
run: |
from gradunwarp.core.globals import VERSION
print(VERSION)
- name: Install pytest
run: pip install pytest
- name: Run tests
run: pytest -v --pyargs gradunwarp

publish:
name: Upload to PyPI
runs-on: ubuntu-latest
environment: "Package deployment"
needs: [test, test-dist]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
150 changes: 0 additions & 150 deletions .github/workflows/wheels.yml

This file was deleted.

14 changes: 1 addition & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[build-system]
requires = [
"setuptools",
# Numpy 1.25 allows back-compiling and supports 3.9
"numpy>=1.25; python_version >= '3.9'",
# Last version to support 3.6-3.8
"numpy==1.19; python_version > '3.0' and python_version < '3.9'",
# Last version to support 2.7
"numpy==1.16; python_version < '3.0'",
]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.bumpver]
Expand All @@ -33,9 +25,5 @@ push = false
"^VERSION = '{version}'"
]

[tool.cibuildwheel]
# Do not bother building pypy wheels
skip = "pp*"

[tool.ruff.extend-per-file-ignores]
"*/__init__.py" = ["F401"]
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ packages = find:
install_requires =
nibabel >= 3.2.1; python_version >= '3.0'
nibabel >= 2.0; python_version < '3.0'
numpy>=1.26.0b1; python_version > '3.11'
numpy; python_version <= '3.11'
numpy
scipy

[options.package_data]
gradunwarp.core.tests = data/*

[bdist_wheel]
universal = 1

0 comments on commit 76f1fd0

Please sign in to comment.