Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ jobs:
- os: ubuntu-24.04-arm
cibw_archs: aarch64
- os: windows-latest
cibw_archs: AMD64 ARM64
cibw_archs: AMD64
- os: windows-11-arm
cibw_archs: ARM64
- os: macos-latest
cibw_archs: universal2

steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v8.2.0

- name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
uses: pypa/cibuildwheel@v3.1.4
uses: pypa/cibuildwheel@v3.4.1
env:
CIBW_BUILD_FRONTEND: build[uv]
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: "pp*"
CIBW_SKIP: "cp39-win_arm64 cp310-win_arm64"
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_TEST_COMMAND: python {project}/tests/test_cases.py
with:
Expand All @@ -37,7 +39,7 @@ jobs:
- name: Run abi3audit
run: uvx abi3audit --report ./wheelhouse/*-abi3-*.whl

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: pycocotools-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
Expand All @@ -50,12 +52,12 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

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

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: pycocotools-sdist
path: ./PythonAPI/dist/*.tar.gz
Expand All @@ -71,7 +73,7 @@ jobs:
id-token: write

steps:
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- numpy>=2.0.0

steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v8.2.0

- name: Fix windows symlink
if: runner.os == 'Windows'
Expand Down
33 changes: 33 additions & 0 deletions PythonAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.15...3.29)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)

find_package(
Python
COMPONENTS Interpreter Development.Module ${SKBUILD_SABI_COMPONENT} NumPy
REQUIRED
)

set(PYX_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/pycocotools/_mask.pyx")
set(GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/_mask.c")

add_custom_command(
OUTPUT "${GENERATED_C}"
MAIN_DEPENDENCY "${PYX_SOURCE}"
VERBATIM
COMMAND Python::Interpreter -m cython "${PYX_SOURCE}" --output-file "${GENERATED_C}"
COMMENT "Generating C source from _mask.pyx"
)

if(NOT "${SKBUILD_SABI_VERSION}" STREQUAL "")
Python_add_library(_mask MODULE "${GENERATED_C}" "${CMAKE_CURRENT_SOURCE_DIR}/common/maskApi.c" WITH_SOABI USE_SABI ${SKBUILD_SABI_VERSION})
else()
Python_add_library(_mask MODULE "${GENERATED_C}" "${CMAKE_CURRENT_SOURCE_DIR}/common/maskApi.c" WITH_SOABI)
endif()

target_include_directories(
_mask PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/common"
${Python_NumPy_INCLUDE_DIRS}
)

install(TARGETS _mask DESTINATION pycocotools)
52 changes: 50 additions & 2 deletions PythonAPI/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@
requires = [
"cython>=3.1.0",
"numpy>=2.0.0,<3",
"setuptools>=70.1.0",
"scikit-build-core>=0.12.0",
]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"

[project]
name = "pycocotools"
version = "2.0.11"
description = "Official APIs for the MS-COCO dataset"
requires-python = ">=3.9"
license.text = "FreeBSD"
dependencies = [
"numpy",
]

[project.readme]
text = '''
# pycocotools

This is a fork of the original [cocoapi](https://github.com/cocodataset/cocoapi), with bug fixes and packaging improvements.

This is also the "official" source of the pypi package `pycocotools`, available for download at [pypi](https://pypi.org/project/pycocotools/).

Changes in this fork include:
* Add CircleCI tests
* Support pip-installation correctly
* Support windows
* Don't import matplotlib unless needed
* Close file handle after openning
* Fix a small bug in rleToBbox
* Fix a segfault in RLE decoding
* Fix deprecated usage of other libraries

For compatibility, we will not make any API changes or non-bug behavior changes to the existing APIs of the official cocoapi.

## Instructions for maintainers: to build a sdist package:
```
python -m build --sdist ./PythonAPI
```
'''
content-type = "text/markdown"

[project.urls]
Homepage = "https://github.com/ppwwyyxx/cocoapi"

[project.optional-dependencies]
all = ["matplotlib>=2.1.0"]

[tool.scikit-build]
cmake.build-type = "Release"
wheel.packages = ["pycocotools"]
wheel.py-api = "cp312"
58 changes: 0 additions & 58 deletions PythonAPI/setup.py

This file was deleted.

Loading