Skip to content

Commit fd8253e

Browse files
authored
~~Build abi3 wheel for python 3.13, 3.14...~~ and build modernizing (#27)
* limited api test * update build * cython? * no compile args * fix abi3audit command * pybuffer 3.11 * fix abi3audit * fix sysconfig Py_GIL_DISABLED * abi3 - python3.12 https://cython.readthedocs.io/en/latest/src/userguide/limited_api.html#performance * Constrains numpy version and updates setuptools https://github.com/scipy/oldest-supported-numpy#deprecation-notice-for-numpy-20 https://setuptools.pypa.io/en/latest/history.html#v70-1-0 * update unittest * fix: remove abi3 features * fix: do not include _mask.c file in the sdist
1 parent 5789ebc commit fd8253e

File tree

5 files changed

+40
-43
lines changed

5 files changed

+40
-43
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,28 @@ jobs:
1010
strategy:
1111
matrix:
1212
include:
13-
- os: ubuntu-latest # linux x86_64
13+
- os: ubuntu-latest
1414
cibw_archs: x86_64
15-
cibw_skip: "pp*"
16-
- os: ubuntu-latest # linux arm64 gnu
15+
- os: ubuntu-24.04-arm
1716
cibw_archs: aarch64
18-
cibw_skip: "pp* *musllinux*"
1917
- os: windows-latest
2018
cibw_archs: AMD64 ARM64
21-
cibw_skip: "pp*"
22-
- os: macos-14
19+
- os: macos-latest
2320
cibw_archs: universal2
24-
cibw_skip: "pp*"
2521

2622
steps:
2723
- uses: actions/checkout@v4
28-
29-
- name: Set up QEMU
30-
if: runner.os == 'Linux' && matrix.cibw_archs == 'aarch64'
31-
uses: docker/setup-qemu-action@v3
32-
with:
33-
platforms: arm64
24+
- uses: astral-sh/setup-uv@v6
3425

3526
- name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
36-
uses: pypa/cibuildwheel@v2.17
27+
uses: pypa/cibuildwheel@v2.23
3728
env:
38-
CIBW_BUILD_FRONTEND: build
29+
CIBW_BUILD_FRONTEND: build[uv]
3930
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
40-
CIBW_SKIP: ${{ matrix.cibw_skip }}
31+
CIBW_SKIP: "pp*"
4132
CIBW_ARCHS: ${{ matrix.cibw_archs }}
33+
CIBW_ENABLE: cpython-freethreading
4234
CIBW_TEST_COMMAND: python {project}/tests/test_cases.py
43-
CIBW_TEST_SKIP: "*-win_arm64 *-musllinux_aarch64"
4435
with:
4536
package-dir: ./PythonAPI
4637

.github/workflows/unittest.yml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,42 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest, windows-latest, macos-latest]
15-
install_from: [source, sdist]
16-
numpy: [oldest-supported-numpy, numpy<2, numpy>=2.0.0rc1]
14+
os:
15+
- ubuntu-latest
16+
- ubuntu-24.04-arm
17+
- macos-latest
18+
- windows-latest
19+
install_from:
20+
- source
21+
- sdist
22+
numpy:
23+
- oldest-supported-numpy
24+
- numpy>=2.0.0
1725

1826
steps:
1927
- uses: actions/checkout@v4
20-
- uses: actions/setup-python@v5
21-
with:
22-
python-version: "3.9"
28+
- uses: astral-sh/setup-uv@v6
2329

2430
- name: Fix windows symlink
25-
if: matrix.os == 'windows-latest'
31+
if: runner.os == 'Windows'
2632
shell: bash
2733
run: rm ./PythonAPI/common && cp -r ./common ./PythonAPI
2834

29-
- name: Install from source
35+
- name: Test from source
3036
if: matrix.install_from == 'source'
37+
shell: bash
3138
run: |
32-
pip install ./PythonAPI '${{ matrix.numpy }}'
33-
python -c "import numpy as np; print(np.__version__)"
39+
for version in 3.9 3.10 3.11 3.12 3.13 3.13t
40+
do
41+
uv run --with ./PythonAPI --with '${{ matrix.numpy }}' --python $version --managed-python tests/test_cases.py
42+
done
3443
35-
- name: Install from sdist
44+
- name: Test from sdist
3645
if: matrix.install_from == 'sdist'
3746
shell: bash
3847
run: |
39-
pipx run build --sdist ./PythonAPI
40-
pip install ./PythonAPI/dist/*.tar.gz '${{ matrix.numpy }}'
41-
python -c "import numpy as np; print(np.__version__)"
42-
43-
- name: Run test cases
44-
run: python tests/test_cases.py
48+
uv build --sdist ./PythonAPI
49+
for version in 3.9 3.10 3.11 3.12 3.13 3.13t
50+
do
51+
uv run --with ./PythonAPI/dist/*.tar.gz --with '${{ matrix.numpy }}' --python $version --managed-python tests/test_cases.py
52+
done

PythonAPI/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
graft ./common
2+
exclude **/*mask.c
3+
include **/*mask.pyx

PythonAPI/pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[build-system]
22
requires = [
3-
"cython>=0.27.3",
4-
"numpy>=2.0.0rc1",
5-
"setuptools>=43.0.0",
6-
"wheel",
3+
"cython>=3.1.0",
4+
"numpy>=2.0.0,<3",
5+
"setuptools>=70.1.0",
76
]
87
build-backend = "setuptools.build_meta"

PythonAPI/setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""To compile and install locally run "python setup.py build_ext --inplace".
22
To install library to Python site-packages run "python -m pip install --use-feature=in-tree-build ."
33
"""
4-
import platform
54
from pathlib import Path
65
from setuptools import setup, Extension
76

87
import numpy as np
8+
from Cython.Build import cythonize
99

1010
ext_modules = [
1111
Extension(
1212
'pycocotools._mask',
1313
sources=['./common/maskApi.c', 'pycocotools/_mask.pyx'],
1414
include_dirs=[np.get_include(), './common'],
15-
extra_compile_args=[] if platform.system()=='Windows' else
16-
['-Wno-cpp', '-Wno-unused-function', '-std=c99'],
1715
)
1816
]
1917

@@ -22,7 +20,6 @@
2220
except FileNotFoundError:
2321
readme = ""
2422

25-
2623
setup(
2724
name='pycocotools',
2825
description='Official APIs for the MS-COCO dataset',
@@ -40,5 +37,5 @@
4037
'all': ['matplotlib>=2.1.0'],
4138
},
4239
version='2.0.9',
43-
ext_modules=ext_modules
40+
ext_modules=cythonize(ext_modules),
4441
)

0 commit comments

Comments
 (0)