Proposed workaround, but would be good to have it standalone
import sys
import os
import ctypes
import sqlite3
from pathlib import Path
import importlib.resources as res
def ensure_mingw_runtime_for_sqlite_vector():
"""Sur Windows, vector.dll dépend souvent de libgcc_s_seh-1.dll (MinGW).
On ajoute un dossier DLL search path pour CE process + précharge les DLL."""
if sys.platform != "win32":
return
candidates = [
r"C:\Program Files\Git\mingw64\bin",
r"C:\Program Files (x86)\Git\mingw64\bin",
]
for d in candidates:
libgcc = Path(d) / "libgcc_s_seh-1.dll"
if libgcc.exists():
# Rend ce dossier visible pour la résolution des dépendances (Windows 10+ / Python 3.8+)
os.add_dll_directory(d)
# Précharge libgcc (et éventuellement les dépendances usuelles)
ctypes.WinDLL(str(libgcc))
for name in ("libstdc++-6.dll", "libwinpthread-1.dll"):
p = Path(d) / name
if p.exists():
ctypes.WinDLL(str(p))
return
raise FileNotFoundError(
"Impossible de trouver libgcc_s_seh-1.dll. "
"Vérifie que Git for Windows (mingw64) est installé, ou ajoute ton dossier MinGW."
)
ensure_mingw_runtime_for_sqlite_vector()
dll = Path(res.files("sqlite_vector.binaries") / "vector.dll")
conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
conn.load_extension(str(dll))
conn.enable_load_extension(False)
print("vector_version:", conn.execute("SELECT vector_version();").fetchone())
print("vector_backend:", conn.execute("SELECT vector_backend();").fetchone())
Proposed workaround, but would be good to have it standalone