Skip to content

Commit

Permalink
Add build wheeel on CI using cibuildwheel and modernize metadata (#147)
Browse files Browse the repository at this point in the history
* add build wheeel on CI and modernize metadata
* add concurency groups
* Allow only binary numpy and scipy
* skip pp37, use prefer binary
* skip only tests
* uimprove workflow name
* skip testing pypy
* skip pp37 on macosx
* skip pypy 3.7 in general
* skip musllinux
* skip pypy 3.10
* skip manylinux i686
* proper skip musllinux
* remve pip verbosity
* add comments with explanation
  • Loading branch information
Czaki committed Apr 17, 2024
1 parent 06305da commit e19a262
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test-python-package-with-conda.yml
Expand Up @@ -2,6 +2,10 @@ name: Test mahotas

on: [push]

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:
build-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -74,7 +78,7 @@ jobs:
numpy-version: '1.22'


# NumPy <1.25 are too old for Python 3.12
# NumPy <=1.25 are too old for Python 3.12
- python-version: '3.12'
numpy-version: '1.19'
- python-version: '3.12'
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/wheel.yml
@@ -0,0 +1,76 @@
name: Build wheel and sdist

on:
push:
tags:
- 'v*'
branches:
- main
- master
- build_wheel
pull_request:

concurrency:
group: wheel-${{ github.ref }}
cancel-in-progress: true

jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
# env:
# CIBW_SOME_OPTION: value
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_all:
needs: [ build_wheels, make_sdist ]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
wheelhouse
dist/
build/
mahotas.egg-info/
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
@@ -0,0 +1,11 @@
[build-system]
requires = ["setuptools", "numpy"]
# When build with numpy>=1.25 the resulted binary wheel is compatybile with numpy >=1.16
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
test-command = "pytest --import-mode=importlib {project}/mahotas/tests"
test-extras = ["tests"]
test-skip = ["pp*", "cp31*-win32"] # there are no scipy weels for this version
skip= ["pp37*", "pp310*", "*musllinux*", "*manylinux*i686"] # there are no numpy wheels for this version
environment = { PIP_PREFER_BINARY="1"}
7 changes: 6 additions & 1 deletion setup.py
Expand Up @@ -98,6 +98,8 @@ def get_include(self):
install_requires = open('requirements.txt').read().strip().split('\n')

tests_require = open('tests-requirements.txt').read().strip().split('\n')
if "freeimage" in tests_require:
tests_require.pop(tests_require.index("freeimage"))

copt={
'msvc': ['/EHsc'],
Expand Down Expand Up @@ -158,6 +160,9 @@ def build_extensions(self):
},
install_requires = install_requires,
tests_require = tests_require,
cmdclass = {'build_ext': build_ext_subclass}
cmdclass = {'build_ext': build_ext_subclass},
extras_require = {
"tests": tests_require,
},
)

0 comments on commit e19a262

Please sign in to comment.