Skip to content
Merged
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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,18 @@ 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
uses: actions/checkout@v4

- 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
26 changes: 15 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,36 @@ 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 && \
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 ;; \
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


WORKDIR /app
COPY . /app
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

RUN micromamba create -y -n test-env -c conda-forge python=3.12 pip compilers
RUN micromamba run -n test-env pip install -e . --group test

SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"]

Expand Down
5 changes: 3 additions & 2 deletions src/spatial_graph/_rtree/src/rtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define RTREE_H

#include <stdlib.h>
#include <stdbool.h>
#include "config.h"

// rtree_new returns a new rtree
Expand Down Expand Up @@ -83,8 +84,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);
Expand Down
16 changes: 6 additions & 10 deletions src/spatial_graph/_rtree/wrapper_template.pyx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
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
#define DIMS $dims
#include <stdbool.h>
#include <string.h>

typedef $coord_dtype.to_pyxtype() coord_t;
typedef $item_dtype.base_c_type item_base_t;
Expand Down Expand Up @@ -152,7 +148,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,
Expand All @@ -174,7 +170,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,
Expand Down Expand Up @@ -203,7 +199,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
Expand Down
Loading