Skip to content

Commit

Permalink
Merge pull request #48 from lgray/patch-1
Browse files Browse the repository at this point in the history
fix: numpy 2.0 compatibility
  • Loading branch information
tpgillam authored Aug 5, 2024
2 parents 646818c + e394384 commit d80c34d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 74 deletions.
90 changes: 40 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,107 +2,97 @@ name: Build

on: [push, pull_request]

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U -r requirements_dev.txt
pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Test with tox numpy>=2
run: tox -e latestnpy
- name: Test with tox numpy<2
run: tox -e oldestnpy

build_wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
name: Build wheel for ${{ matrix.os }}-cp${{ matrix.python }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python: [36, 37, 38, 39]
bitness: [32, 64]
manylinux_image: [manylinux1, manylinux2010]
include:
# Run 32 and 64 bit version in parallel for Linux and Windows
- os: windows-latest
bitness: 64
platform_id: win_amd64
- os: windows-latest
bitness: 32
platform_id: win32
- os: ubuntu-latest
bitness: 64
platform_id: manylinux_x86_64
python: [38, 39, 310, 311, 312]
arch: [auto64, auto32, universal2]
build: ["cp"]
exclude:
- os: ubuntu-latest
bitness: 32
platform_id: manylinux_i686
- os: macos-latest
bitness: 64
platform_id: macosx_x86_64
exclude:
- os: macos-latest
bitness: 32
# Remove manylinux1 from the windows and osx build matrix since
# manylinux_image is not used for these platforms
arch: universal2
- os: windows-latest
manylinux_image: manylinux1
arch: universal2
- os: macos-latest
manylinux_image: manylinux1
arch: auto32
steps:
- name: Checkout mt2
uses: actions/checkout@v2
uses: actions/checkout@v4

# Used to host cibuildwheel
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.9.0

- name: Build wheels
- uses: pypa/[email protected]
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
run: python -m cibuildwheel --output-dir wheelhouse
CIBW_BUILD: "${{ matrix.build }}${{ matrix.python }}*"
CIBW_ARCHS: ${{ matrix.arch }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.8"
python-version: "3.12"

- name: Install numpy (imported by setup.py)
run: python -m pip install numpy
- name: Install numpy and setuptools
run: python -m pip install numpy setuptools

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
with:
path: dist/*.tar.gz

pass:
needs: [test, build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- run: echo "All jobs passed"

upload_pypi:
needs: [build_wheels, build_sdist, test]
runs-on: ubuntu-latest
Expand All @@ -111,7 +101,7 @@ jobs:
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
requires = [
"setuptools",
"wheel",

# Use the oldest possible version of numpy for building. This ensures maximal
# compatibility.
"oldest-supported-numpy",
"numpy>=1.19.3",
]
22 changes: 11 additions & 11 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pip==19.2.3
numpy==1.19.2
bump2version==0.5.11
wheel==0.33.6
watchdog==0.9.0
flake8==3.7.8
tox==3.14.0
coverage==4.5.4
twine==1.14.0
pip
numpy>=1.19.3
bump2version
wheel
watchdog
flake8
tox
coverage
twine

pytest==4.6.5
pytest-runner==5.1
pytest
pytest-runner
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
description="Stransverse mass computation as a numpy ufunc.",
install_requires=["numpy"],
install_requires=["numpy>=1.19.3"],
license="MIT license",
long_description=readme + "\n\n" + history,
include_package_data=True,
Expand Down
24 changes: 19 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[tox]
envlist = py36, py37, py38, py39, flake8
envlist = py39, py310, py311, py312, flake8

[gh-actions]
python =
3.9: py39
3.8: py38
3.7: py37
3.6: py36
3.10: py310
3.11: py311
3.12: py312

[testenv:flake8]
basepython = python
deps = flake8
commands = flake8 mt2 tests

[testenv]
[testenv:latestnpy]
setenv =
PYTHONPATH = {toxinidir}
deps =
Expand All @@ -25,3 +25,17 @@ commands =
pip install -U pip
pytest --basetemp={envtmpdir}

[testenv:oldestnpy]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
; If you want to make tox run the tests with the same versions, create a
; requirements.txt with the pinned versions and uncomment the following line:
; -r{toxinidir}/requirements.txt
commands =
pip uninstall -y numpy
pip install -U pip
pip install oldest-supported-numpy
pytest --basetemp={envtmpdir}

0 comments on commit d80c34d

Please sign in to comment.