Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4554c5b
Fix intersection bug and add Python 3.13 support (v0.7.0)
devin-ai-integration[bot] Nov 2, 2025
198394d
Implement precision-matching with input validation and fix parallel i…
devin-ai-integration[bot] Nov 2, 2025
2aaace7
Fix macOS CI failure - guard against hardware_concurrency() returning 0
devin-ai-integration[bot] Nov 2, 2025
5d611dc
Drop Python 3.6/3.7 support and add Python 3.14 support
devin-ai-integration[bot] Nov 2, 2025
85aad26
Upgrade cibuildwheel to v2.20.0 and add Python 3.13/3.14 support
devin-ai-integration[bot] Nov 2, 2025
474b9a3
Upgrade cibuildwheel to v3.2.1 for full Python 3.13/3.14 support
devin-ai-integration[bot] Nov 2, 2025
20e7269
Update CMake minimum version from 3.0 to 3.5 for cibuildwheel v3.x co…
devin-ai-integration[bot] Nov 2, 2025
16ad79c
Update cereal to latest version (v1.3.2) for CMake 3.5+ compatibility
devin-ai-integration[bot] Nov 2, 2025
beb0131
Update submodules to latest versions for Python 3.13/3.14 compatibility
devin-ai-integration[bot] Nov 2, 2025
51c36e4
Fix serialization bug and packaging issues for macOS/Windows
atksh Nov 2, 2025
ff48f6a
Fix macOS/Windows CI failures: static linking and architecture settings
atksh Nov 2, 2025
65db6ad
Fix Windows CI failures: MSVC-specific settings and debug prelude
atksh Nov 2, 2025
ddf6496
Fix extension module packaging for Windows/macOS multi-config generators
atksh Nov 2, 2025
9d39b88
Fix extension module packaging for macOS/Windows multi-config generators
atksh Nov 2, 2025
6b70c28
Fix pybind11 Python detection for macOS-14 ARM64 builds
atksh Nov 2, 2025
45cbdcc
Fix pybind11 constructor overload resolution for Python 3.8 Windows
atksh Nov 2, 2025
56e9a94
Fix CI artifact naming conflict
atksh Nov 2, 2025
df4a624
Add musllinux and Windows ARM64 platform support
atksh Nov 2, 2025
9221bdd
Fix musllinux configuration for cibuildwheel 3.x
atksh Nov 2, 2025
8f11e60
Fix Windows ARM64 cross-compilation support
atksh Nov 2, 2025
6e29db3
Remove Windows ARM64 support (cross-compilation issues)
atksh Nov 2, 2025
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
172 changes: 127 additions & 45 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ jobs:
matrix:
include:
# Window 64 bit
# Note: windows-2019 is needed for older Python versions:
# https://github.com/scikit-learn/scikit-learn/issues/22530
- os: windows-2019
python: 36
platform_id: win_amd64
arch: AMD64
- os: windows-2019
python: 37
platform_id: win_amd64
arch: AMD64
- os: windows-2019
# Note: Python 3.6 and 3.7 dropped due to pybind11 v2.13.6 requiring Python >=3.7
# and Python 3.7 being EOL (June 2023). Minimum supported version is now Python 3.8.
- os: windows-latest
python: 38
platform_id: win_amd64
arch: AMD64
Expand All @@ -51,118 +43,191 @@ jobs:
python: 312
platform_id: win_amd64
arch: AMD64
- os: windows-latest
python: 313
platform_id: win_amd64
arch: AMD64
- os: windows-latest
python: 314
platform_id: win_amd64
arch: AMD64

# Linux 64 bit manylinux2014
# Python 3.6 and 3.7 dropped (see Windows section comment)
- os: ubuntu-latest
python: 36
python: 38
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
arch: x86_64
- os: ubuntu-latest
python: 37
python: 39
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
arch: x86_64
- os: ubuntu-latest
python: 38
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
arch: x86_64
- os: ubuntu-latest
python: 39
python: 311
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
arch: x86_64
- os: ubuntu-latest
python: 310
python: 312
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
arch: x86_64
- os: ubuntu-latest
python: 311
python: 313
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
manylinux_image: manylinux_2_28
arch: x86_64
- os: ubuntu-latest
python: 312
python: 314
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
manylinux_image: manylinux_2_28
arch: x86_64

# Linux 64 bit aarch64
# Python 3.6 and 3.7 dropped (see Windows section comment)
- os: ubuntu-latest
python: 36
python: 38
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
arch: aarch64
- os: ubuntu-latest
python: 37
python: 39
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
arch: aarch64
- os: ubuntu-latest
python: 38
python: 310
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
arch: aarch64
- os: ubuntu-latest
python: 39
python: 311
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
arch: aarch64
- os: ubuntu-latest
python: 310
python: 312
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
arch: aarch64
- os: ubuntu-latest
python: 311
python: 313
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
manylinux_image: manylinux_2_28
arch: aarch64
- os: ubuntu-latest
python: 312
python: 314
platform_id: manylinux_aarch64
manylinux_image: manylinux2014
manylinux_image: manylinux_2_28
arch: aarch64

# MacOS x86_64
# Python 3.6 and 3.7 dropped (see Windows section comment)
- os: macos-13
python: 36
python: 38
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 37
python: 39
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 38
python: 310
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 39
python: 311
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 310
python: 312
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 311
python: 313
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64
- os: macos-13
python: 312
python: 314
platform_id: macosx_x86_64
macosx_deployment_target: 10.14
arch: x86_64

# Linux musllinux x86_64 (Alpine Linux)
# Note: cibuildwheel 3.x auto-selects appropriate musllinux images
- os: ubuntu-latest
python: 38
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 39
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 310
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 311
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 312
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 313
platform_id: musllinux_x86_64
arch: x86_64
- os: ubuntu-latest
python: 314
platform_id: musllinux_x86_64
arch: x86_64

# Linux musllinux aarch64 (Alpine Linux ARM64)
# Note: cibuildwheel 3.x auto-selects appropriate musllinux images
- os: ubuntu-latest
python: 38
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 39
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 310
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 311
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 312
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 313
platform_id: musllinux_aarch64
arch: aarch64
- os: ubuntu-latest
python: 314
platform_id: musllinux_aarch64
arch: aarch64

# MacOS arm64
- os: macos-14
python: 38
Expand All @@ -189,10 +254,20 @@ jobs:
platform_id: macosx_arm64
macosx_deployment_target: 11.7
arch: arm64
- os: macos-14
python: 313
platform_id: macosx_arm64
macosx_deployment_target: 11.7
arch: arm64
- os: macos-14
python: 314
platform_id: macosx_arm64
macosx_deployment_target: 11.7
arch: arm64


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
Expand All @@ -201,29 +276,33 @@ jobs:
python-version: '3.10'
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v3.2.1
env:
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_BEFORE_BUILD: pip install pybind11
CIBW_TEST_COMMAND: pytest {project}/tests -vv
CIBW_TEST_COMMAND: python {project}/tests/_ci_debug_import.py && pytest {project}/tests -vv
CIBW_TEST_COMMAND_WINDOWS: python {project}\tests\_ci_debug_import.py && pytest {project}\tests -vv
CIBW_TEST_REQUIRES: pytest numpy
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS: ${{ matrix.arch }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform_id }}-py${{ matrix.python }}
path: ./wheelhouse/*.whl
overwrite: true

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
Expand All @@ -232,20 +311,23 @@ jobs:
python-version: '3.10'
- name: Build sdist
run: python setup.py sdist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
overwrite: true

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: artifact
pattern: '*'
path: dist
merge-multiple: true
- uses: pypa/[email protected]
with:
user: __token__
Expand Down
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

if(WIN32)
set(CMAKE_CXX_FLAGS "/O3 /pthread")
set(CMAKE_CXX_FLAGS "/O2 /EHsc")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "-O3 -pthread")
else()
Expand All @@ -16,6 +16,11 @@ option(SNAPPY_BUILD_TESTS "" OFF)
option(SNAPPY_BUILD_BENCHMARKS "" OFF)
option(SNAPPY_INSTALL "" OFF)

option(SKIP_PERFORMANCE_COMPARISON "" ON)
option(BUILD_TESTS "" OFF)
option(BUILD_SANDBOX "" OFF)
option(BUILD_DOC "" OFF)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/pybind11/)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/cereal/)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/snappy/)
Expand All @@ -40,4 +45,13 @@ set_target_properties(PRTree PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
INTERPROCEDURAL_OPTIMIZATION TRUE
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}"
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG}"
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE}"
)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ Note that cross-version compatibility is **NOT** guaranteed, so please reconstru

## New Features and Changes

### `python-prtree>=0.7.0`

**BREAKING CHANGES:**

- **Fixed critical intersection bug**: Boxes with small gaps (< 1e-5) were incorrectly reported as intersecting due to float32 precision loss. Now uses precision-matching two-stage approach: float32 input → pure float32 performance, float64 input → float32 tree + double-precision refinement for correctness.
- **Python version requirements**: Minimum Python version is now 3.8 (dropped 3.6 and 3.7 due to pybind11 v2.13.6 compatibility). Added support for Python 3.13 and 3.14.
- **Serialization format changed**: Binary files saved with previous versions are incompatible with 0.7.0+. You must rebuild and re-save your trees after upgrading.
- **Updated pybind11**: Upgraded from v2.12.0 to v2.13.6 for Python 3.13+ support.
- **Input validation**: Added validation to reject NaN/Inf coordinates and enforce min <= max per dimension.
- **Improved test coverage**: Added comprehensive tests for edge cases including disjoint boxes with small gaps, touching boxes, large magnitude coordinates, and degenerate boxes.

**Bug Fix Details:**

The bug occurred when two bounding boxes were separated by a very small gap (e.g., 5.39e-06). When converted from float64 to float32, the values would collapse to the same float32 value, causing the intersection check to incorrectly report them as intersecting. This has been fixed by implementing a precision-matching approach: float32 input uses pure float32 for speed, while float64 input uses a two-stage filter-then-refine approach (float32 tree + double-precision refinement) for correctness.

### `python-prtree>=0.5.8`

- The insert method has been improved to select the node with the smallest mbb expansion.
Expand Down
Loading
Loading