From 3bfaf18e2446ce92333eddbb3550401eb642742d Mon Sep 17 00:00:00 2001 From: Dan Bauman Date: Fri, 2 Jan 2026 11:04:25 -0500 Subject: [PATCH 1/2] updates --- CMakeLists.txt | 46 ++++++++++++++++++------- bsonsearch/CMakeLists.txt | 2 +- lib/tests/bsoncompare_projection.c | 11 ++++++ pyproject.toml | 2 +- third-party/CMakeLists.txt | 22 +++++++++--- third-party/libsodium-1.0.20.tar.gz | 3 ++ third-party/mongo-c-driver-2.2.0.tar.gz | 3 ++ third-party/mongo-c-driver-2.2.1.tar.gz | 3 ++ 8 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 third-party/libsodium-1.0.20.tar.gz create mode 100644 third-party/mongo-c-driver-2.2.0.tar.gz create mode 100644 third-party/mongo-c-driver-2.2.1.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b35ece..a9578e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) project(bsonsearch) - +set(MONGOC_VERSION "2.2.1") # Default cmake includes all features and modules # Optional "lite" version available with only bson and pcre dependencies # mkdir cmake-build-lite && cd cmake-build-lite @@ -16,23 +16,39 @@ project(bsonsearch) include_directories( ${CMAKE_BINARY_DIR}/usr/include/ - ${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2 + ${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION} lib/ /usr/include/ ) list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_BINARY_DIR}/usr/include/ - /opt/homebrew/include/ ) +if(EXISTS "/opt/homebrew/include") + message("/opt/homebrew exists, adding it to include path") + list(APPEND CMAKE_REQUIRED_INCLUDES + /opt/homebrew/include/ + ) +endif() + +# RHEL-based systems use lib64 +if(EXISTS "/usr/lib64") + message("---- appears to be RHEL-based system") + LINK_DIRECTORIES( + ${CMAKE_BINARY_DIR}/usr/lib + ${CMAKE_BINARY_DIR}/usr/lib64 + /usr/local/lib/ + /usr/lib64/ + lib/acceleration/ + ) +else() + LINK_DIRECTORIES( + ${CMAKE_BINARY_DIR}/usr/lib + /usr/local/lib/ + /usr/local/lib/ + lib/acceleration/ + ) +endif() -LINK_DIRECTORIES( - ${CMAKE_BINARY_DIR}/usr/lib - ${CMAKE_BINARY_DIR}/usr/lib64 - /usr/local/lib/ - /usr/lib64/ - /usr/local/lib/ - lib/acceleration/ -) ## SECTION 1 -- COMPILE Checks @@ -57,7 +73,7 @@ option(include-text "include-text" OFF) option(include-ip "include-ip" OFF) option(include-yara "include-yara" OFF) -option(include-crypt "include-crypt" OFF) +option(include-crypt "include-crypt" ON) option(include-modules "include-modules" ON) CMAKE_DEPENDENT_OPTION(include-math "include-math" ON "include-modules" OFF) @@ -77,6 +93,10 @@ if (APPLE OR build-dependencies) message("-- requested dukjs with -D include-dukjs") add_definitions(-DWITH_DUKJS) endif() + if (include-crypt) + message("-- requested libsodium with -D include-crypt") + add_definitions(-DWITH_CRYPT) + endif () endif() add_subdirectory(third-party) @@ -93,7 +113,7 @@ else() return() endif() message("-- Looking for include file bson.h") - find_path(HAVE_BSON_H bson.h PATHS third-party/usr/include/bson-2.1.2/bson ) + find_path(HAVE_BSON_H bson.h PATHS third-party/usr/include/bson-${MONGOC_VERSION}/bson ) if(NOT HAVE_BSON_H) message(SEND_ERROR "BSON is required, stopping") return() diff --git a/bsonsearch/CMakeLists.txt b/bsonsearch/CMakeLists.txt index fc1019f..421f9f5 100644 --- a/bsonsearch/CMakeLists.txt +++ b/bsonsearch/CMakeLists.txt @@ -7,7 +7,7 @@ file(COPY "${CMAKE_SOURCE_DIR}/setup.py" DESTINATION "${CMAKE_BINARY_DIR}/") add_custom_target(pybsonsearch ALL - COMMAND LIB_DIR=${CMAKE_BINARY_DIR}:${CMAKE_BINARY_DIR}/usr/lib/ INCLUDE_DIR=${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/lib/:${CMAKE_BINARY_DIR}/usr/include/:${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2 ${Python_EXECUTABLE} -m build; + COMMAND LIB_DIR=${CMAKE_BINARY_DIR}:${CMAKE_BINARY_DIR}/usr/lib/ INCLUDE_DIR=${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/lib/:${CMAKE_BINARY_DIR}/usr/include/:${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION} ${Python_EXECUTABLE} -m build; COMMAND rm -rf bsonsearch WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Making the python library via cmake is a confusing" diff --git a/lib/tests/bsoncompare_projection.c b/lib/tests/bsoncompare_projection.c index bec31f1..9d72b89 100644 --- a/lib/tests/bsoncompare_projection.c +++ b/lib/tests/bsoncompare_projection.c @@ -84,6 +84,17 @@ int main (int argc, char *argv[]) { + + + //test foundin command with deep doc + + do { + BSON_ASSERT(test_bson_api("{\"a\": {\"x\": {\"f\":{\"i\": 1}}, \"y\": {\"f\":{\"j\": 2}}, \"z\": {\"f\":{\"k\": 3}}}}", + "{\"$project\":{\"a\":{\"$foundin\":[\"a.$any.f\"]}}}", + "{ \"a\" : [ { \"i\" : 1 }, { \"j\" : 2 }, { \"k\" : 3 } ] }")); + }while(false);//*/ + + //FIXED: too many embedded dict are failing. do { //project follows at least once checking. diff --git a/pyproject.toml b/pyproject.toml index 5bbe62c..e872764 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "bsonsearch" -version = "2.1.2" +version = "2.2.1" description = "compare BSON/JSON documents locally" requires-python = ">=3.11" dependencies = [] diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index d5e57ce..f07b39a 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -7,7 +7,7 @@ if (APPLE OR build-dependencies) cmake_policy(SET CMP0135 NEW) endif() - include_directories(${CMAKE_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/usr/include/ ${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2 /usr/include/ lib/ lib/acceleration/) + include_directories(${CMAKE_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/usr/include/ ${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION} /usr/include/ lib/ lib/acceleration/) list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_BINARY_DIR}/usr/include/ ${CMAKE_BINARY_DIR}/third-party @@ -27,11 +27,23 @@ if (APPLE OR build-dependencies) move_file(${CMAKE_SOURCE_DIR}/third-party/pcre-8.45.tar.gz) move_file(${CMAKE_SOURCE_DIR}/third-party/duktape-2.7.0.tar.xz) move_file(${CMAKE_SOURCE_DIR}/third-party/discodb-0.9.5.tar.gz) - move_file(${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-2.1.2.tar.gz) + move_file(${CMAKE_SOURCE_DIR}/third-party/libsodium-1.0.20.tar.gz) + move_file(${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-${MONGOC_VERSION}.tar.gz) file(COPY "${CMAKE_SOURCE_DIR}/third-party/uthash.h" DESTINATION "${CMAKE_BINARY_DIR}/usr/include") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/discodb_build") + ExternalProject_Add( + ExternalSodium # Name for the external project + URL "file:///${CMAKE_SOURCE_DIR}/third-party/libsodium-1.0.20.tar.gz" # Path to your tarball + URL_HASH "SHA256=ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19" + SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/sodium_src" + BINARY_DIR "${CMAKE_BINARY_DIR}/third-party/sodium_src" + INSTALL_DIR "${CMAKE_BINARY_DIR}/usr" + CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/usr + BUILD_COMMAND make + INSTALL_COMMAND make install + ) ExternalProject_Add( ExternalPCRE # Name for the external project @@ -43,6 +55,7 @@ if (APPLE OR build-dependencies) CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/usr --enable-utf --enable-jit=auto --enable-pcre32 --enable-pcre16 --enable-pcre8 --disable-cpp --enable-newline-is-anycrlf --with-match-limit=100; BUILD_COMMAND make INSTALL_COMMAND make install + DEPENDS ExternalSodium ) @@ -57,6 +70,7 @@ if (APPLE OR build-dependencies) BUILD_COMMAND make -f Makefile.sharedlibrary INSTALL_PREFIX=${CMAKE_BINARY_DIR}/usr INSTALL_COMMAND make -f Makefile.sharedlibrary INSTALL_PREFIX=${CMAKE_BINARY_DIR}/usr install BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/third-party/usr/libduktape.so" + DEPENDS ExternalSodium ) add_custom_target(ExternalDuktapeDebuggerFix COMMAND cp usr/lib/libduktape*.so .; @@ -112,8 +126,8 @@ if (APPLE OR build-dependencies) ) ExternalProject_Add( mongoccompile # Name for the external project - URL "file:///${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-2.1.2.tar.gz" # Path to your tarball - URL_HASH "SHA256=faf1666b0447b6108211a5ff74cd354d982edc9d89727cfd651b2ce6ef319531" + URL "file:///${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-${MONGOC_VERSION}.tar.gz" # Path to your tarball + URL_HASH "SHA256=bc56f9acd91454eca5121e030fc1bb236283a94f4522b749beeb55e5e30343fb" SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/mongoc_src" BINARY_DIR "${CMAKE_BINARY_DIR}/third-party/mongoc_build" INSTALL_DIR "${CMAKE_BINARY_DIR}/usr" diff --git a/third-party/libsodium-1.0.20.tar.gz b/third-party/libsodium-1.0.20.tar.gz new file mode 100644 index 0000000..df6c124 --- /dev/null +++ b/third-party/libsodium-1.0.20.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19 +size 1925167 diff --git a/third-party/mongo-c-driver-2.2.0.tar.gz b/third-party/mongo-c-driver-2.2.0.tar.gz new file mode 100644 index 0000000..10cf68a --- /dev/null +++ b/third-party/mongo-c-driver-2.2.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6117f90a5f0ff0a37cdf01710344925649e1432460b905cd1570d95a94a7ff10 +size 7862224 diff --git a/third-party/mongo-c-driver-2.2.1.tar.gz b/third-party/mongo-c-driver-2.2.1.tar.gz new file mode 100644 index 0000000..b7f1a9e --- /dev/null +++ b/third-party/mongo-c-driver-2.2.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc56f9acd91454eca5121e030fc1bb236283a94f4522b749beeb55e5e30343fb +size 7863924 From bf5f0572eedaa786b4ad0c570e8950687c3db216 Mon Sep 17 00:00:00 2001 From: Dan Bauman Date: Fri, 2 Jan 2026 11:15:18 -0500 Subject: [PATCH 2/2] updates --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 281666a..4a38ebb 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,9 @@ from os import environ include_dirs = [ - f"/usr/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/", - f"/usr/local/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/", - f"/opt/homebrew/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/", + f"/usr/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/", + f"/usr/local/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/", + f"/opt/homebrew/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/", "/opt/homebrew/include/", "/usr/local/" ]