mirror of
https://github.com/hanzoai/replicate.git
synced 2026-10-30 18:23:20 +00:00
- All source files, configs, docs, CI renamed - Binary: replicate (not litestream) - Config: replicate.yml (litestream.yml as fallback) - Env: REPLICATE_* (LITESTREAM_* as fallback) - Socket: /var/run/replicate.sock - Image: ghcr.io/hanzoai/replicate - Module: github.com/hanzoai/replicate - Package name: replicate (Go), replicate-vfs (npm/pip/gem) - VFS: registered as "replicate", pragmas replicate_* - C exports: ReplicateVFSRegister, GoReplicate* - Windows service: Replicate - Systemd unit: replicate.service - Upstream attribution preserved (README, upgrade test scripts)
34 lines
910 B
Python
34 lines
910 B
Python
"""Replicate VFS extension for SQLite."""
|
|
|
|
import os
|
|
import sys
|
|
|
|
_EXT_MAP = {
|
|
"linux": "replicate-vfs.so",
|
|
"darwin": "replicate-vfs.dylib",
|
|
}
|
|
|
|
|
|
def loadable_path():
|
|
"""Return the filesystem path to the loadable VFS extension."""
|
|
platform = sys.platform
|
|
if platform.startswith("linux"):
|
|
platform = "linux"
|
|
filename = _EXT_MAP.get(platform)
|
|
if filename is None:
|
|
raise OSError(f"Unsupported platform: {sys.platform}")
|
|
path = os.path.join(os.path.dirname(__file__), filename)
|
|
if not os.path.exists(path):
|
|
raise FileNotFoundError(f"VFS extension not found at {path}")
|
|
return path
|
|
|
|
|
|
def load(conn):
|
|
"""Load the Replicate VFS extension into a sqlite3 connection."""
|
|
path = loadable_path()
|
|
conn.enable_load_extension(True)
|
|
try:
|
|
conn.load_extension(os.path.splitext(path)[0])
|
|
finally:
|
|
conn.enable_load_extension(False)
|