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
37 changes: 19 additions & 18 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:
PYTHONUTF8: 1
PYTHONFAULTHANDLER: 1
PYTHON_VERSION: 3.11
DOTNET_VERSION: 8.0.x
NODE_VERSION: 20
DOTNET_VERSION: 10.0.x
NODE_VERSION: 24
JAVA_VERSION: 21
GO_VERSION: "^1.22.0"
ANDROID_NDK_VERSION: 26.3.11579264
GO_VERSION: "^1.25.0"
ANDROID_NDK_VERSION: 27.2.12479018
ANDROID_SDK_VERSION: 21

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand Down Expand Up @@ -137,6 +137,7 @@ jobs:
run: |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp
Expand Down Expand Up @@ -218,6 +219,7 @@ jobs:
run: |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp
Expand Down Expand Up @@ -307,8 +309,8 @@ jobs:
# C/C++
- name: Build C/C++
run: |
choco install cmake
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0
choco install cmake -y
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0 -D USEARCH_USE_NUMKONG=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: .\build_artifacts\test_cpp.exe
Expand Down Expand Up @@ -353,11 +355,13 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Test .NET
shell: pwsh
run: |
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp

test_windows_arm:
Expand Down Expand Up @@ -404,7 +408,7 @@ jobs:
needs: [test_ubuntu_gcc, test_ubuntu_clang]
strategy:
matrix:
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
python-version: ["310", "311", "312", "313", "314", "314t"]
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -420,7 +424,7 @@ jobs:
max_attempts: 3
retry_wait_seconds: 10
timeout_minutes: 180
command: python -m pip install cibuildwheel
command: python -m pip install "cibuildwheel~=4.1"
- name: Build wheels
uses: nick-fields/retry@v4
with:
Expand All @@ -430,7 +434,6 @@ jobs:
command: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ENABLE: cpython-freethreading
CIBW_PLATFORM: linux

build_wheels_macos:
Expand All @@ -439,7 +442,7 @@ jobs:
needs: [test_macos]
strategy:
matrix:
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
python-version: ["310", "311", "312", "313", "314", "314t"]
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -453,7 +456,7 @@ jobs:
max_attempts: 3
retry_wait_seconds: 10
timeout_minutes: 180
command: python -m pip install cibuildwheel
command: python -m pip install "cibuildwheel~=4.1"
- name: Build wheels
uses: nick-fields/retry@v4
with:
Expand All @@ -463,7 +466,6 @@ jobs:
command: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ENABLE: cpython-freethreading
CIBW_PLATFORM: macos

build_wheels_windows:
Expand All @@ -472,7 +474,7 @@ jobs:
needs: [test_windows_x86]
strategy:
matrix:
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
python-version: ["310", "311", "312", "313", "314", "314t"]
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -486,7 +488,7 @@ jobs:
max_attempts: 3
retry_wait_seconds: 10
timeout_minutes: 180
command: python -m pip install cibuildwheel
command: python -m pip install "cibuildwheel~=4.1"
- name: Build wheels
uses: nick-fields/retry@v4
with:
Expand All @@ -496,7 +498,6 @@ jobs:
command: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ENABLE: cpython-freethreading
CIBW_PLATFORM: windows

test_ubuntu_cross_compilation:
Expand Down
66 changes: 38 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ env:
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
PYTHONUTF8: 1
PYTHON_VERSION: 3.11
DOTNET_VERSION: 8.0.x
NODE_VERSION: 20
DOTNET_VERSION: 10.0.x
NODE_VERSION: 24
JAVA_VERSION: 21
GO_VERSION: "^1.22.0"
ANDROID_NDK_VERSION: 26.3.11579264
GO_VERSION: "^1.25.0"
ANDROID_NDK_VERSION: 27.2.12479018
ANDROID_SDK_VERSION: 21
EMSCRIPTEN_VERSION: 3.1.47
MINGW_VERSION: 12.2.0
EMSCRIPTEN_VERSION: 6.0.2

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand Down Expand Up @@ -195,10 +194,9 @@ jobs:

- name: Setup MinGW
if: matrix.arch != 'arm64'
uses: egor-tensin/setup-mingw@v2
uses: egor-tensin/setup-mingw@v3
with:
platform: ${{ matrix.arch }}
version: ${{ env.MINGW_VERSION }}

- name: Setup MSVC for ARM64
if: matrix.arch == 'arm64'
Expand Down Expand Up @@ -750,7 +748,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-24.04, macos-14, windows-2022]
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
python-version: ["310", "311", "312", "313", "314", "314t"]
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
Expand All @@ -767,12 +765,11 @@ jobs:
if: matrix.os == 'ubuntu-24.04' # We only need QEMU for Linux builds
uses: docker/setup-qemu-action@v3
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
run: python -m pip install "cibuildwheel~=4.1"
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ENABLE: cpython-freethreading # No-GIL 3.13t builds
CIBW_TEST_SKIP: "*-win_arm64" # Too complex to emulate Windows ARM
- name: Upload wheels
uses: actions/upload-artifact@v5
Expand Down Expand Up @@ -813,19 +810,9 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: [x64, x86]
# Windows pre-build is not working
# - windows-latest
os: [macos-14, ubuntu-24.04]
exclude:
- arch: x86
os: macos-14
- arch: x86
os: ubuntu-24.04
arch: [x64]
os: [macos-14, ubuntu-24.04, windows-2022]
runs-on: ${{ matrix.os }}
env:
CC: gcc
CXX: g++

steps:
- name: Checkout the latest code
Expand All @@ -852,7 +839,16 @@ jobs:
run: |
npm install --ignore-scripts
- run: npm run prebuild-single
if: matrix.os != 'macos-14'
env:
CC: gcc
CXX: g++
if: matrix.os == 'ubuntu-24.04'
# Leave CC/CXX unset on Windows. node-gyp builds with MSVC regardless,
# but NumKong's ISA probe takes the compiler from $CC while still
# passing MSVC flag syntax, so a `gcc` here fails every probe and
# silently yields a scalar-only binary with no SIMD kernels.
- run: npm run prebuild-single
if: matrix.os == 'windows-2022'
- run: npm run prebuild-darwin-x64+arm64
env:
CC: clang
Expand Down Expand Up @@ -1136,6 +1132,7 @@ jobs:
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"

- name: Build C library for MacOS
if: matrix.os == 'macos-15'
Expand All @@ -1146,15 +1143,19 @@ jobs:
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"

- name: Build C library for Windows
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
choco install cmake
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=0 -DUSEARCH_USE_JEMALLOC=0
choco install cmake -y
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=1 -DUSEARCH_USE_JEMALLOC=0
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir

- name: Upload Artifacts
uses: actions/upload-artifact@v5
Expand Down Expand Up @@ -1188,6 +1189,15 @@ jobs:
merge-multiple: true
path: ${{ env.USEARCH_LIBS }}

- name: Verify native package inputs
run: |
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libusearch_c.so"
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libnumkong.so"
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libusearch_c.dylib"
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libnumkong.dylib"
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/libusearch_c.dll"
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/numkong.dll"

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ function (setup_target TARGET_NAME)
if (USEARCH_USE_NUMKONG AND TARGET nk_shared)
target_compile_definitions(${TARGET_NAME} PRIVATE "NK_DYNAMIC_DISPATCH=1")
target_link_libraries(${TARGET_NAME} PRIVATE nk_shared)

# Keep NumKong discoverable both in the build tree (`build/numkong`) and
# after packaging it next to `libusearch_c` in language bindings.
if (APPLE)
set(_USEARCH_NUMKONG_RPATH "@loader_path;@loader_path/numkong")
elseif (UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(_USEARCH_NUMKONG_RPATH "$ORIGIN;$ORIGIN/numkong")
endif ()

if (DEFINED _USEARCH_NUMKONG_RPATH)
set_target_properties(
${TARGET_NAME} PROPERTIES BUILD_RPATH "${_USEARCH_NUMKONG_RPATH}"
INSTALL_RPATH "${_USEARCH_NUMKONG_RPATH}"
)
endif ()
endif ()

endfunction ()
Expand All @@ -394,6 +409,19 @@ if (USEARCH_USE_NUMKONG)

if (TARGET nk_shared)
set_target_properties(nk_shared PROPERTIES ENABLE_EXPORTS ON)

# Windows has no RPATH equivalent, so the dynamic loader only finds
# NumKong reliably when it sits next to the binaries that link it.
if (WIN32)
set_target_properties(
nk_shared
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
)
endif ()
endif ()
endif ()

Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ Then, on Windows, copy the library to the CSharp project and run the tests:
```sh
mkdir -p ".\csharp\lib\runtimes\win-x64\native"
cp ".\build_artifacts\libusearch_c.dll" ".\csharp\lib\runtimes\win-x64\native"
cp ".\build_artifacts\numkong.dll" ".\csharp\lib\runtimes\win-x64\native"
cd csharp
dotnet test -c Debug --logger "console;verbosity=detailed"
dotnet test -c Release
Expand All @@ -494,8 +495,10 @@ On Linux, the process is similar:
```sh
mkdir -p "csharp/lib/runtimes/linux-x64/native" # for x86
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-x64/native" # for x86
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-x64/native" # for x86
mkdir -p "csharp/lib/runtimes/linux-arm64/native" # for ARM
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
cd csharp
dotnet test -c Debug --logger "console;verbosity=detailed"
dotnet test -c Release
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
description = "Smaller & Faster Single-File Vector Search Engine from Unum"
documentation = "https://unum-cloud.github.io/USearch"
edition = "2021"
edition = "2024"
include = [
"/rust/**",
"/include/**",
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'cpp'
id 'maven-publish'
id 'signing'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.diffplug.spotless' version '8.8.0'
}

group = "cloud.unum"
Expand Down Expand Up @@ -57,14 +57,15 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
}

dependencies {
testImplementation('junit:junit:4.13.2')
testImplementation('org.junit.jupiter:junit-jupiter:5.12.2')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
}

spotless {
format 'gradle', {
target '*.gradle'
trimTrailingWhitespace()
indentWithSpaces(4)
leadingTabsToSpaces(4)
endWithNewline()
}

Expand Down Expand Up @@ -196,6 +197,7 @@ model {
}

test {
useJUnitPlatform()
forkEvery = 1

dependsOn jar
Expand Down
Loading
Loading