Skip to content
Open
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
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ jobs:
with:
name: sqlite-vec-windows-x86_64-extension
path: dist/*
build-windows-aarch64-extension:
runs-on: windows-11-arm
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: arm64
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: ./scripts/vendor.sh
shell: bash
- run: make sqlite-vec.h
- run: mkdir dist
- run: cl.exe /W4 /Ivendor/ /O2 /LD sqlite-vec.c /Fedist\vec0.dll
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-windows-aarch64-extension
path: dist/*
build-linux-aarch64-extension:
runs-on: ubuntu-22.04-arm
steps:
Expand Down Expand Up @@ -188,6 +209,7 @@ jobs:
build-macos-x86_64-extension,
build-macos-aarch64-extension,
build-windows-x86_64-extension,
build-windows-aarch64-extension,
build-wasm32-emscripten,
build-android-extensions,
build-ios-extensions,
Expand Down Expand Up @@ -219,6 +241,10 @@ jobs:
with:
name: sqlite-vec-windows-x86_64-extension
path: dist/windows-x86_64
- uses: actions/download-artifact@v4
with:
name: sqlite-vec-windows-aarch64-extension
path: dist/windows-aarch64
- uses: actions/download-artifact@v4
with:
name: sqlite-vec-wasm32-emscripten
Expand Down Expand Up @@ -284,6 +310,7 @@ jobs:
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec-linux-x64.tar.gz
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec-linux-arm64.tar.gz
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec-windows-x64.tar.gz
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec-windows-arm64.tar.gz
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec-wasm-demo.tar.gz
npm publish --provenance --access public --tag $TAG .sqlite-dist/npm/sqlite-vec.tar.gz
env:
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,37 @@ jobs:
- run: make sqlite-vec.h
- run: mkdir dist
- run: cl.exe /fPIC -shared /W4 /Ivendor/ /O2 /LD sqlite-vec.c -o dist/vec0.dll
- run: uv sync --directory tests
- run: make test-loadable-sync
shell: bash
- run: make test-loadable
shell: bash
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-windows-x86_64-extension
path: dist/*
build-windows-aarch64-extension:
runs-on: windows-11-arm
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: arm64
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- run: ./scripts/vendor.sh
shell: bash
- run: make sqlite-vec.h
- run: mkdir dist
- run: cl.exe /W4 /Ivendor/ /O2 /LD sqlite-vec.c /Fedist\vec0.dll
- run: make test-loadable-sync
shell: bash
- run: make test-loadable
shell: bash
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-windows-aarch64-extension
path: dist/*
build-linux-aarch64-extension:
runs-on: ubuntu-22.04-arm
steps:
Expand Down
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
COMMIT=$(shell git rev-parse HEAD)
VERSION=$(shell cat VERSION)
DATE=$(shell date +'%FT%TZ%z')
UNAME_S=$(shell uname -s 2>/dev/null)
UNAME_M=$(shell uname -m 2>/dev/null)

INSTALL_LIB_DIR = /usr/local/lib
INSTALL_INCLUDE_DIR = /usr/local/include
Expand All @@ -14,10 +16,12 @@ ifndef AR
AR=ar
endif

ifeq ($(shell uname -s),Darwin)
ifeq ($(UNAME_S),Darwin)
CONFIG_DARWIN=y
else ifeq ($(OS),Windows_NT)
CONFIG_WINDOWS=y
else ifneq ($(filter MINGW% MSYS% CYGWIN%,$(UNAME_S)),)
CONFIG_WINDOWS=y
else
CONFIG_LINUX=y
endif
Expand All @@ -35,6 +39,21 @@ ifdef CONFIG_WINDOWS
LOADABLE_EXTENSION=dll
endif

TEST_LOADABLE_UV_RUN_ARGS ?= --managed-python
TEST_LOADABLE_UV_SYNC_ARGS ?=

ifdef CONFIG_WINDOWS
# Windows-on-ARM can surface different architecture strings depending on
# whether the current shell is native or x64-emulated, so inspect both the
# Windows processor env vars and the current shell/dev-command hints before
# choosing Python.
WINDOWS_HOST_ARCH_HINTS := $(PROCESSOR_ARCHITEW6432) $(PROCESSOR_ARCHITECTURE) $(VSCMD_ARG_TGT_ARCH) $(Platform) $(UNAME_S) $(UNAME_M)
ifneq ($(strip $(findstring ARM64,$(WINDOWS_HOST_ARCH_HINTS))$(findstring arm64,$(WINDOWS_HOST_ARCH_HINTS))$(findstring AARCH64,$(WINDOWS_HOST_ARCH_HINTS))$(findstring aarch64,$(WINDOWS_HOST_ARCH_HINTS))),)
TEST_LOADABLE_UV_RUN_ARGS = --python python
TEST_LOADABLE_UV_SYNC_ARGS = --python python
endif
endif

ifndef OMIT_SIMD
ifeq ($(shell uname -sm),Darwin x86_64)
CFLAGS += -mavx -DSQLITE_VEC_ENABLE_AVX
Expand Down Expand Up @@ -174,17 +193,20 @@ evidence-of:
test:
sqlite3 :memory: '.read test.sql'

.PHONY: version loadable static test clean gh-release evidence-of install uninstall
.PHONY: version loadable static test clean gh-release evidence-of install uninstall test-loadable-sync test-loadable test-loadable-snapshot-update test-loadable-watch

publish-release:
./scripts/publish-release.sh

# -k test_vec0_update
test-loadable-sync:
uv sync --directory tests $(TEST_LOADABLE_UV_SYNC_ARGS)

test-loadable: loadable
uv run --managed-python --project tests pytest -vv -s -x . tests/test-*.py
uv run $(TEST_LOADABLE_UV_RUN_ARGS) --project tests pytest -vv -s -x . tests/test-*.py

test-loadable-snapshot-update: loadable
uv run --managed-python --project tests pytest -vv tests/test-loadable.py --snapshot-update
uv run $(TEST_LOADABLE_UV_RUN_ARGS) --project tests pytest -vv tests/test-loadable.py --snapshot-update

test-loadable-watch:
watchexec --exts c,py,Makefile --clear -- make test-loadable
Expand Down
7 changes: 3 additions & 4 deletions sqlite-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,9 @@ static f32 distance_hamming_u8(u8 *a, u8 *b, size_t n) {

#ifdef _MSC_VER
#if !defined(__clang__) && (defined(_M_ARM) || defined(_M_ARM64))
// From
// https://github.com/ngtcp2/ngtcp2/blob/b64f1e77b5e0d880b93d31f474147fae4a1d17cc/lib/ngtcp2_ringbuf.c,
// line 34-43
static unsigned int __builtin_popcountl(unsigned int x) {
// MSVC on Windows ARM lacks __popcnt64, but this code path counts bits from
// 64-bit lanes in distance_hamming_u64().
static unsigned int __builtin_popcountl(u64 x) {
unsigned int c = 0;
for (; x; ++c) {
x &= x - 1;
Expand Down
1 change: 1 addition & 0 deletions tests/test-loadable.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def test_vec_distance_hamming():
assert vec_distance_hamming(b"\xff", b"\x00") == 8
assert vec_distance_hamming(b"\xff", b"\x01") == 7
assert vec_distance_hamming(b"\xab", b"\xab") == 0
assert vec_distance_hamming(b"\x00\x00\x00\x00\xff\xff\xff\xff", b"\x00" * 8) == 32

with pytest.raises(
sqlite3.OperationalError,
Expand Down
Loading