Skip to content

Include numpy 2 compatibility layer #208

Include numpy 2 compatibility layer

Include numpy 2 compatibility layer #208

Workflow file for this run

## These options mostly follow the ones used in
## https://github.com/matplotlib/matplotlib/blob/main/.github/workflows/cibuildwheel.yml, though I
## try to be a little less complicated.
name: tests
on:
push:
branches:
- main
tags: '*'
pull_request:
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
jobs:
get_new_version:
name: Get new version number
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.get_version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.12'
- name: Install Hatch
shell: bash
run: python -m pip install --disable-pip-version-check --upgrade hatch
- name: Bump version
id: get_version
shell: bash
env:
github_event_head_commit_message: ${{ github.event.head_commit.message }}
run: |
# Note: The following line reads the HEAD commit message to look for an indication of how
# to bump the version number. Specifically, if `#patch`, `#minor`, or `#major` is present
# in the commit message, it bumps the corresponding version number. Those can also be
# prepended as `#premajor`, etc., to add/bump the prerelease modifier. If none of those
# are present, `#patch` is assumed — that is, the lowest-significance number is
# incremented. See the documentation of the `hatch version` command for details.
export version_bump_rule=$(python .github/scripts/parse_bump_rule.py)
echo "version_bump_rule: '${version_bump_rule}'"
hatch version "${version_bump_rule}"
export new_version=$(TERM="unknown" hatch version)
echo "new_version: '${new_version}'"
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT" # Save variable for later steps
build_wheels:
needs: get_new_version
name: Build wheels on ${{ matrix.os }} for ${{matrix.archs}}
runs-on: ${{ matrix.os }}
if: >-
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
archs: ["auto"]
include:
- os: ubuntu-latest
archs: "aarch64"
env:
CIBW_ARCHS: ${{matrix.archs}}
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_BEFORE_BUILD: python -c "print(('#'*130+'\n')*10)" && python -m pip install "numpy>=2.0,<3"
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: "pytest {project}/tests"
CIBW_SKIP: "*-win32 *-manylinux_i686 cp36-* cp37-* cp38-* cp39-* pp* *-musllinux* cp313-*"
# Exclude 32-bit builds: *-win32 *-manylinux_i686
# Exclude python versions not supported by numpy: cp36-* cp37-* cp38-* cp39-* pp*
# Exclude musllinux builds: *-musllinux*
# Exclude python versions not yet supported by numba: cp313-*
# https://numpy.org/neps/nep-0029-deprecation_policy.html
# https://numba.readthedocs.io/en/stable/user/installing.html#numba-support-info
steps:
- name: Set up QEMU
if: matrix.archs == 'aarch64'
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: "Check out code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.12'
- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel
- name: Build wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3 # Don't upgrade to v4 until each artifact is named
with:
path: ./wheelhouse/*.whl
build_sdist:
needs: get_new_version
name: Build source distribution
runs-on: ubuntu-latest
if: >-
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
steps:
- name: 'Check out code'
uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.12'
- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py
- name: Build sdist
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade "setuptools>=61" wheel "numpy>=2.0,<3"
python setup.py sdist
- uses: actions/upload-artifact@v3 # Don't upgrade to v4 until each artifact is named
with:
path: dist/*.tar.gz
upload_pypi:
needs: [get_new_version, build_wheels, build_sdist]
name: Tag and release
runs-on: ubuntu-latest
if: >-
github.ref == 'refs/heads/main'
&& !contains(github.event.head_commit.message, '[no release]')
&& (success() || contains(github.event.head_commit.message, '[skip tests]'))
environment: release
permissions: write-all
# actions: write
# checks: write
# contents: write
# deployments: write
# id-token: write
# issues: write
# discussions: write
# packages: write
# pages: write
# pull-requests: write
# repository-projects: write
# security-events: write
# statuses: write
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: actions/download-artifact@v3 # Don't upgrade to v4 until each artifact is named
with:
name: artifact
path: dist
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.12'
- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py
- name: Tag and push new version
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.new_version}}
git config user.name github-actions
git config user.email github-actions@github.com
git commit -m "Update version for new release" pyproject.toml setup.py src/quaternion/__init__.py
git tag -a "v${new_version}" -m "Version ${new_version}"
git status
git push --follow-tags # Will not trigger new workflow because it uses GITHUB_TOKEN
- name: Create release
if: "!contains(github.event.head_commit.message, '[no release]')"
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.get_new_version.outputs.new_version }}
name: Release v${{ needs.get_new_version.outputs.new_version }}
draft: false
prerelease: false
- name: Publish to PyPI
if: "!contains(github.event.head_commit.message, '[no pypi]')"
env:
# 1) Get key from https://pypi.org/manage/account/token/
# 2) Copy it to Github > repo > Settings > Secrets
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
shell: bash
run: |
hatch publish