Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wheel files that support numpy 2.0 #24

Merged
merged 12 commits into from
Apr 10, 2024
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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to break python3.7 & 3.8 users?

3.8 seems to have a good amount of users: https://pypistats.org/packages/pycocotools

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because numpy no longer supports versions lower than 3.9 😿.
https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table

The other dependency, matplotlib, also does not support below 3.9.
https://github.com/matplotlib/matplotlib/blob/d45dfbb245b991e51f60a5083d61d0130b2ecc1b/pyproject.toml#L45

By modifying python_requires in setup.py, we can ensure that pycocotools 2.0.7 is selected for Python 3.8 and below. (pip or other dependency manager select the appropriate version.)

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