From 4397533eaf2a871744adbe605d201f93b310d30a Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 14:34:53 -0400 Subject: [PATCH 1/7] break docker --- Dockerfile | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 349d162..993246d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,42 @@ FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive \ - MAMBA_ROOT_PREFIX=/opt/conda \ - PATH=/opt/conda/bin:$PATH + MAMBA_ROOT_PREFIX=/opt/conda \ + PATH=/opt/conda/bin:$PATH RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - git curl tar bzip2 ca-certificates && \ - rm -rf /var/lib/apt/lists/* + apt-get install -y --no-install-recommends \ + git curl tar bzip2 ca-certificates && \ + rm -rf /var/lib/apt/lists/* # auto-detect arch and grab the matching micromamba binary RUN set -eux; \ - arch="$(uname -m)"; \ - case "$arch" in \ - x86_64) url_arch=linux-64 ;; \ - aarch64|arm64) url_arch=linux-aarch64 ;; \ - ppc64le) url_arch=linux-ppc64le ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ - esac; \ - curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ - | tar -xvj -C /usr/local/bin bin/micromamba; \ - chmod +x /usr/local/bin/bin/micromamba; \ - mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \ - rmdir /usr/local/bin/bin + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64) url_arch=linux-64 ;; \ + aarch64|arm64) url_arch=linux-aarch64 ;; \ + ppc64le) url_arch=linux-ppc64le ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ + esac; \ + curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ + | tar -xvj -C /usr/local/bin bin/micromamba; \ + chmod +x /usr/local/bin/bin/micromamba; \ + mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \ + rmdir /usr/local/bin/bin WORKDIR /app COPY . /app -RUN micromamba create -y -n test-env -c conda-forge python=3.12 pip compilers +# Conditionally install the correct gxx_linux package based on architecture +RUN set -eux; \ + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64) gxx_pkg=gxx_linux-64 ;; \ + aarch64|arm64) gxx_pkg=gxx_linux-aarch64 ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ + esac; \ + micromamba create -y -n test-env -c conda-forge python=3.12 pip gxx "$gxx_pkg"=15.* RUN micromamba run -n test-env pip install -e . --group test SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"] From 8682d9add5821bb4d54ea4e2352d300b7982c314 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 14:37:09 -0400 Subject: [PATCH 2/7] reduce diff --- Dockerfile | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 993246d..910be46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,28 @@ FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive \ - MAMBA_ROOT_PREFIX=/opt/conda \ - PATH=/opt/conda/bin:$PATH + MAMBA_ROOT_PREFIX=/opt/conda \ + PATH=/opt/conda/bin:$PATH RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - git curl tar bzip2 ca-certificates && \ - rm -rf /var/lib/apt/lists/* + apt-get install -y --no-install-recommends \ + git curl tar bzip2 ca-certificates && \ + rm -rf /var/lib/apt/lists/* # auto-detect arch and grab the matching micromamba binary RUN set -eux; \ - arch="$(uname -m)"; \ - case "$arch" in \ - x86_64) url_arch=linux-64 ;; \ - aarch64|arm64) url_arch=linux-aarch64 ;; \ - ppc64le) url_arch=linux-ppc64le ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ - esac; \ - curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ - | tar -xvj -C /usr/local/bin bin/micromamba; \ - chmod +x /usr/local/bin/bin/micromamba; \ - mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \ - rmdir /usr/local/bin/bin + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64) url_arch=linux-64 ;; \ + aarch64|arm64) url_arch=linux-aarch64 ;; \ + ppc64le) url_arch=linux-ppc64le ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ + esac; \ + curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ + | tar -xvj -C /usr/local/bin bin/micromamba; \ + chmod +x /usr/local/bin/bin/micromamba; \ + mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \ + rmdir /usr/local/bin/bin WORKDIR /app @@ -30,14 +30,13 @@ COPY . /app # Conditionally install the correct gxx_linux package based on architecture RUN set -eux; \ - arch="$(uname -m)"; \ - case "$arch" in \ - x86_64) gxx_pkg=gxx_linux-64 ;; \ - aarch64|arm64) gxx_pkg=gxx_linux-aarch64 ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ - esac; \ - micromamba create -y -n test-env -c conda-forge python=3.12 pip gxx "$gxx_pkg"=15.* -RUN micromamba run -n test-env pip install -e . --group test + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64) gxx_pkg=gxx_linux-64 ;; \ + aarch64|arm64) gxx_pkg=gxx_linux-aarch64 ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ + esac; \ + micromamba create -y -n test-env -c conda-forge python=3.12 pip gxx "$gxx_pkg"=15.* SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"] From 35c5ff7f9851a58cf26140df496a1167fb417898 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 14:51:44 -0400 Subject: [PATCH 3/7] try fix --- src/spatial_graph/_rtree/src/rtree.h | 4 ++-- src/spatial_graph/_rtree/wrapper_template.pyx | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/spatial_graph/_rtree/src/rtree.h b/src/spatial_graph/_rtree/src/rtree.h index dfa8e73..66745c0 100644 --- a/src/spatial_graph/_rtree/src/rtree.h +++ b/src/spatial_graph/_rtree/src/rtree.h @@ -83,8 +83,8 @@ int rtree_delete(struct rtree *tr, const coord_t *min, const coord_t *max, const // rectangle, and perform a comparison of its data to the provided data using // a compare function. The first item that is found is deleted. // -// Returns false if the system is out of memory. -bool rtree_delete_with_comparator(struct rtree *tr, const coord_t *min, +// Returns the number of deleted items (0 or 1) or -1 if an OOM error occured. +int rtree_delete_with_comparator(struct rtree *tr, const coord_t *min, const coord_t *max, const item_t item, int (*compare)(const item_t a, const item_t b, void *udata), void *udata); diff --git a/src/spatial_graph/_rtree/wrapper_template.pyx b/src/spatial_graph/_rtree/wrapper_template.pyx index f0844b6..e36791a 100644 --- a/src/spatial_graph/_rtree/wrapper_template.pyx +++ b/src/spatial_graph/_rtree/wrapper_template.pyx @@ -1,15 +1,9 @@ from libc.stdint cimport * +from libcpp cimport bool import numpy as np - -ctypedef int bool - cdef extern from *: """ - typedef int bool; - #define false 0 - #define true 1 - %if $c_distance_function #define KNN_USE_EXACT_DISTANCE %end if @@ -152,7 +146,7 @@ cdef pyx_items_t memview_to_pyx_items_t($item_dtype.to_pyxtype(add_dim=True) ite %end if -cdef bint count_iterator( +cdef bool count_iterator( const coord_t* bb_min, const coord_t* bb_max, const item_t item, @@ -174,7 +168,7 @@ cdef init_search_results_from_memview(search_results* r, $item_dtype.to_pyxtype( r.items = memview_to_pyx_items_t(items) -cdef bint search_iterator( +cdef bool search_iterator( const coord_t* bb_min, const coord_t* bb_max, const item_t item, @@ -203,7 +197,7 @@ cdef init_nearest_results_from_memview(nearest_results* r, r.distances = &distances[0] if distances is not None else NULL -cdef bint nearest_iterator( +cdef bool nearest_iterator( const item_t item, coord_t distance, void* udata From 9dc018df17456e4d72a41c410690e2530b73c2aa Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 17:53:14 -0400 Subject: [PATCH 4/7] more fix --- src/spatial_graph/_rtree/src/rtree.h | 1 + src/spatial_graph/_rtree/wrapper_template.pyx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/spatial_graph/_rtree/src/rtree.h b/src/spatial_graph/_rtree/src/rtree.h index 66745c0..3217e9d 100644 --- a/src/spatial_graph/_rtree/src/rtree.h +++ b/src/spatial_graph/_rtree/src/rtree.h @@ -6,6 +6,7 @@ #define RTREE_H #include +#include #include "config.h" // rtree_new returns a new rtree diff --git a/src/spatial_graph/_rtree/wrapper_template.pyx b/src/spatial_graph/_rtree/wrapper_template.pyx index e36791a..c378085 100644 --- a/src/spatial_graph/_rtree/wrapper_template.pyx +++ b/src/spatial_graph/_rtree/wrapper_template.pyx @@ -8,6 +8,8 @@ cdef extern from *: #define KNN_USE_EXACT_DISTANCE %end if #define DIMS $dims + #include + #include typedef $coord_dtype.to_pyxtype() coord_t; typedef $item_dtype.base_c_type item_base_t; From ed91495553c128b9de3daa123008f22e791bfe8e Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 17:55:41 -0400 Subject: [PATCH 5/7] add back install --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 910be46..12eda59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,7 @@ RUN set -eux; \ *) echo "Unsupported arch: $arch"; exit 1 ;; \ esac; \ micromamba create -y -n test-env -c conda-forge python=3.12 pip gxx "$gxx_pkg"=15.* +RUN micromamba run -n test-env pip install -e . --group test SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"] From b589c56f123397616167e278807233c29ce0bf9c Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 18:02:26 -0400 Subject: [PATCH 6/7] matrix --- .github/workflows/ci.yml | 7 ++++++- Dockerfile | 28 +++++++++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f1027c..d05a605 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,7 +95,12 @@ jobs: files: "./dist/*" docker-test: + name: Docker Test gxx${{ matrix.gxx_major }} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + gxx_major: [14, 15] steps: - name: Checkout code @@ -103,5 +108,5 @@ jobs: - name: Build and test Docker image run: | - docker build -t spatial_graph . + docker build --build-arg GXX_MAJOR=${{ matrix.gxx_major }} -t spatial_graph . docker run --rm spatial_graph diff --git a/Dockerfile b/Dockerfile index 12eda59..69fade2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ ENV DEBIAN_FRONTEND=noninteractive \ MAMBA_ROOT_PREFIX=/opt/conda \ PATH=/opt/conda/bin:$PATH +# Allow overriding the major GCC/G++ version at build time (e.g. --build-arg GXX_MAJOR=14) +ARG GXX_MAJOR=15 + RUN apt-get update && \ apt-get install -y --no-install-recommends \ git curl tar bzip2 ca-certificates && \ @@ -13,32 +16,23 @@ RUN apt-get update && \ RUN set -eux; \ arch="$(uname -m)"; \ case "$arch" in \ - x86_64) url_arch=linux-64 ;; \ - aarch64|arm64) url_arch=linux-aarch64 ;; \ - ppc64le) url_arch=linux-ppc64le ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ + x86_64) url_arch=linux-64; gxx_pkg=gxx_linux-64 ;; \ + aarch64|arm64) url_arch=linux-aarch64; gxx_pkg=gxx_linux-aarch64 ;; \ + ppc64le) url_arch=linux-ppc64le; gxx_pkg=gxx_linux-ppc64le ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ esac; \ curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ | tar -xvj -C /usr/local/bin bin/micromamba; \ chmod +x /usr/local/bin/bin/micromamba; \ mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \ - rmdir /usr/local/bin/bin - + rmdir /usr/local/bin/bin; \ + micromamba create -y -n test-env -c conda-forge \ + python=3.12 pip gxx "${gxx_pkg}=${GXX_MAJOR}.*"; \ + micromamba run -n test-env pip install -e . --group test WORKDIR /app COPY . /app -# Conditionally install the correct gxx_linux package based on architecture -RUN set -eux; \ - arch="$(uname -m)"; \ - case "$arch" in \ - x86_64) gxx_pkg=gxx_linux-64 ;; \ - aarch64|arm64) gxx_pkg=gxx_linux-aarch64 ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ - esac; \ - micromamba create -y -n test-env -c conda-forge python=3.12 pip gxx "$gxx_pkg"=15.* -RUN micromamba run -n test-env pip install -e . --group test - SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"] From c476531befc6309af29b02148ecd0d0b01131c00 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 24 Jul 2025 18:05:40 -0400 Subject: [PATCH 7/7] fix docker --- Dockerfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 69fade2..d5d8214 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,18 @@ RUN apt-get update && \ git curl tar bzip2 ca-certificates && \ rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY . /app + # auto-detect arch and grab the matching micromamba binary RUN set -eux; \ arch="$(uname -m)"; \ case "$arch" in \ - x86_64) url_arch=linux-64; gxx_pkg=gxx_linux-64 ;; \ - aarch64|arm64) url_arch=linux-aarch64; gxx_pkg=gxx_linux-aarch64 ;; \ - ppc64le) url_arch=linux-ppc64le; gxx_pkg=gxx_linux-ppc64le ;; \ - *) echo "Unsupported arch: $arch"; exit 1 ;; \ + x86_64) url_arch=linux-64; gxx_pkg=gxx_linux-64 ;; \ + aarch64|arm64) url_arch=linux-aarch64; gxx_pkg=gxx_linux-aarch64 ;; \ + ppc64le) url_arch=linux-ppc64le; gxx_pkg=gxx_linux-ppc64le ;; \ + *) echo "Unsupported arch: $arch"; exit 1 ;; \ esac; \ curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \ | tar -xvj -C /usr/local/bin bin/micromamba; \ @@ -30,8 +34,6 @@ RUN set -eux; \ python=3.12 pip gxx "${gxx_pkg}=${GXX_MAJOR}.*"; \ micromamba run -n test-env pip install -e . --group test -WORKDIR /app -COPY . /app SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"]