Skip to content

Commit

Permalink
Wheel files that support numpy 2.0 (#24)
Browse files Browse the repository at this point in the history
* update build action

* update actions versions

* update build-system numpy

* ci: test with numpy 2.0.0b1

* ci: numpy rc1

* ci: update build archs

* ci: musllinux, win arm test skip, unique artifact name

* ci: bump unittest.yml actions version

* ci: unittest with various numpy version

* ci: fix unittest python version -> 3.9

* ci: fix install numpy and packages at the same time

Due to potential matplotlib version compatibility issues

* fix: minimum required python version
  • Loading branch information
Bing-su authored Apr 10, 2024
1 parent 4670067 commit f2417e1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
46 changes: 28 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,51 @@ on:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
cibw_archs: auto64
- os: ubuntu-latest
- os: ubuntu-latest # linux x86_64
cibw_archs: x86_64
cibw_skip: "pp*"
- os: ubuntu-latest # linux arm64 gnu
cibw_archs: aarch64
cibw_skip: "pp* *musllinux*"
- os: ubuntu-latest # linux arm64 musl
cibw_archs: aarch64
cibw_skip: "pp* *manylinux*"
- os: windows-latest
cibw_archs: auto64
- os: macos-latest
cibw_archs: AMD64 ARM64
cibw_skip: "pp*"
- os: macos-14
cibw_archs: universal2
cibw_skip: "pp*"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v2
if: runner.os == 'Linux' && matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Build wheels
uses: pypa/cibuildwheel@v2.14
- name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
uses: pypa/cibuildwheel@v2.17
env:
CIBW_BUILD_FRONTEND: build
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
CIBW_SKIP: "pp* *musllinux*"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: ${{ matrix.cibw_skip }}
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_TEST_COMMAND: python {project}/tests/test_cases.py
CIBW_TEST_SKIP: "*-win_arm64 *-musllinux_aarch64"
with:
package-dir: ./PythonAPI

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

test_source:
Expand All @@ -51,13 +60,14 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist ./PythonAPI

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

publish:
Expand All @@ -71,10 +81,10 @@ jobs:
id-token: write

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
merge-multiple: true

- name: Display structure of downloaded files
run: ls -R dist
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ on:

jobs:
test:
name: Test on ${{ matrix.os }}, ${{ matrix.install_from }}
name: Test on ${{ matrix.os }}, ${{ matrix.install_from }}, ${{ matrix.numpy }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
install_from: [source, source_with_pre, sdist]
install_from: [source, sdist]
numpy: [oldest-supported-numpy, numpy<2, numpy>=2.0.0rc1]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.9"

- name: Fix windows symlink
if: matrix.os == 'windows-latest'
Expand All @@ -27,19 +28,17 @@ jobs:

- name: Install from source
if: matrix.install_from == 'source'
run: pip install ./PythonAPI

- name: Install from source with prerelease.
if: matrix.install_from == 'source_with_pre'
# This tests compatibility with pre-release dependencies
run: pip install --pre ./PythonAPI
run: |
pip install ./PythonAPI '${{ matrix.numpy }}'
python -c "import numpy as np; print(np.__version__)"
- name: Install from sdist
if: matrix.install_from == 'sdist'
shell: bash
run: |
pipx run build --sdist ./PythonAPI
pip install ./PythonAPI/dist/*.tar.gz
pip install ./PythonAPI/dist/*.tar.gz '${{ matrix.numpy }}'
python -c "import numpy as np; print(np.__version__)"
- name: Run test cases
run: python tests/test_cases.py
2 changes: 1 addition & 1 deletion PythonAPI/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"cython>=0.27.3",
"oldest-supported-numpy",
"numpy>=2.0.0rc1",
"setuptools>=43.0.0",
"wheel",
]
Expand Down
2 changes: 1 addition & 1 deletion PythonAPI/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
license="FreeBSD",
packages=['pycocotools'],
package_dir={'pycocotools': 'pycocotools'},
python_requires='>=3.5',
python_requires='>=3.9',
install_requires=[
'matplotlib>=2.1.0',
'numpy',
Expand Down

0 comments on commit f2417e1

Please sign in to comment.