Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix: use abi3 for rust package (#1517)

MaojiaSheng21ba377a9c14
diff --git a/Makefile b/Makefile
index 881b22e16..869095450 100644
--- a/Makefile
+++ b/Makefile
@@ -100,7 +100,7 @@ build: check-deps check-pip
fi; \
if [ -n "$$MATURIN_CMD" ]; then \
TMPDIR=$$(mktemp -d); \
- cd crates/ragfs-python && $$MATURIN_CMD build --release --features s3 --out "$$TMPDIR" 2>&1; \
+ cd crates/ragfs-python && $$MATURIN_CMD build --release --out "$$TMPDIR" 2>&1; \
cd ../..; \
mkdir -p openviking/lib; \
echo "import zipfile, glob, shutil, os, sys" > /tmp/extract_ragfs.py; \
diff --git a/crates/ragfs-python/Cargo.toml b/crates/ragfs-python/Cargo.toml
index 15d528598..b82c41cbe 100644
--- a/crates/ragfs-python/Cargo.toml
+++ b/crates/ragfs-python/Cargo.toml
@@ -16,6 +16,6 @@ s3 = ["ragfs/s3"]
[dependencies]
ragfs = { path = "../ragfs" }
-pyo3 = { version = "0.27", features = ["extension-module"] }
+pyo3 = { version = "0.27", features = ["extension-module", "abi3", "abi3-py310"] }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0"
diff --git a/crates/ragfs-python/pyproject.toml b/crates/ragfs-python/pyproject.toml
index 560397e40..eb3445e29 100644
--- a/crates/ragfs-python/pyproject.toml
+++ b/crates/ragfs-python/pyproject.toml
@@ -8,4 +8,6 @@ version = "0.1.0"
requires-python = ">=3.10"
[tool.maturin]
-features = ["pyo3/extension-module"]
+features = ["s3"]
+abi3 = true
+python-source = "3.10"
diff --git a/openviking/pyagfs/__init__.py b/openviking/pyagfs/__init__.py
index 6ae6bc8cc..e24b8e481 100644
--- a/openviking/pyagfs/__init__.py
+++ b/openviking/pyagfs/__init__.py
@@ -6,6 +6,7 @@ import glob
import importlib.util
import logging
import os
+import sys
import sysconfig
from pathlib import Path
@@ -49,12 +50,19 @@ def _find_ragfs_so():
"""
try:
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
- # Exact match first: ragfs_python.cpython-312-darwin.so
+ # Exact match first: ragfs_python.cpython-312-darwin.so or ragfs_python.abi3.so
exact = _LIB_DIR / f"ragfs_python{ext_suffix}"
if exact.exists():
return str(exact)
- # Glob fallback: ragfs_python.cpython-*.so / ragfs_python.*.pyd
- for pattern in ("ragfs_python.cpython-*", "ragfs_python.*"):
+ # Try abi3 suffix explicitly first (stable ABI)
+ abi3_suffix = ".abi3.so"
+ if sys.platform == "win32":
+ abi3_suffix = ".abi3.pyd"
+ abi3_exact = _LIB_DIR / f"ragfs_python{abi3_suffix}"
+ if abi3_exact.exists():
+ return str(abi3_exact)
+ # Glob fallback: ragfs_python.cpython-*, ragfs_python.abi3.*, ragfs_python.*.pyd
+ for pattern in ("ragfs_python.cpython-*", "ragfs_python.abi3.*", "ragfs_python.*"):
matches = glob.glob(str(_LIB_DIR / pattern))
if matches:
return matches[0]
diff --git a/openviking/storage/viking_fs.py b/openviking/storage/viking_fs.py
index 6c99752dc..c6f6bc82f 100644
--- a/openviking/storage/viking_fs.py
+++ b/openviking/storage/viking_fs.py
@@ -1319,13 +1319,13 @@ class VikingFS:
def _ls_entries(self, path: str) -> List[Dict[str, Any]]:
"""List directory entries, filtering out internal directories.
- At account root (/local/{account}), uses VALID_SCOPES whitelist.
+ At account root (/local/{account}), uses LISTABLE_SCOPES whitelist.
At other levels, uses _INTERNAL_NAMES blacklist.
"""
entries = self.agfs.ls(path)
parts = [p for p in path.strip("/").split("/") if p]
if len(parts) == 2 and parts[0] == "local":
- return [e for e in entries if e.get("name") in VikingURI.VALID_SCOPES]
+ return [e for e in entries if e.get("name") in VikingURI.LISTABLE_SCOPES]
return [e for e in entries if e.get("name") not in self._INTERNAL_NAMES]
def _path_to_uri(self, path: str, ctx: Optional[RequestContext] = None) -> str:
diff --git a/openviking_cli/utils/uri.py b/openviking_cli/utils/uri.py
index 67126e27b..9d5cef91e 100644
--- a/openviking_cli/utils/uri.py
+++ b/openviking_cli/utils/uri.py
@@ -32,7 +32,15 @@ class VikingURI:
"""
SCHEME = "viking"
- VALID_SCOPES = {"resources", "user", "agent", "session", "queue", "temp"}
+ # SCOPES that can be listed in root directory (ov ls)
+ LISTABLE_SCOPES = {
+ "resources",
+ "user",
+ "agent",
+ "session",
+ }
+ # All valid scopes that can be visited/accessed
+ VISITABLE_SCOPES = LISTABLE_SCOPES | {"temp", "queue"}
def __init__(self, uri: str):
"""
@@ -70,8 +78,8 @@ class VikingURI:
# Parse scope
scope = path.split("/")[0]
- if scope not in self.VALID_SCOPES:
- raise ValueError(f"Invalid scope '{scope}'. Must be one of {self.VALID_SCOPES}")
+ if scope not in self.VISITABLE_SCOPES:
+ raise ValueError(f"Invalid scope '{scope}'. Must be one of {self.VISITABLE_SCOPES}")
return {
"scheme": self.SCHEME,
@@ -178,14 +186,16 @@ class VikingURI:
Build a Viking URI from components.
Args:
- scope: Scope (resources, user, agent, session, queue)
+ scope: Scope (resources, user, agent, session, queue, temp)
*path_parts: Additional path components
Returns:
Viking URI string
"""
- if scope not in VikingURI.VALID_SCOPES:
- raise ValueError(f"Invalid scope '{scope}'. Must be one of {VikingURI.VALID_SCOPES}")
+ if scope not in VikingURI.VISITABLE_SCOPES:
+ raise ValueError(
+ f"Invalid scope '{scope}'. Must be one of {VikingURI.VISITABLE_SCOPES}"
+ )
parts = [scope] + list(path_parts)
# Filter out empty parts
diff --git a/setup.py b/setup.py
index e82478c26..4ba813a73 100644
--- a/setup.py
+++ b/setup.py
@@ -269,8 +269,6 @@ class OpenVikingBuildExt(build_ext):
"maturin",
"build",
"--release",
- "--features",
- "s3",
"--out",
tmpdir,
]
@@ -306,7 +304,7 @@ class OpenVikingBuildExt(build_ext):
with zipfile.ZipFile(str(whl_files[0])) as zf:
for name in zf.namelist():
basename = Path(name).name
- # Match: ragfs_python.cpython-312-darwin.so, ragfs_python.cp312-win_amd64.pyd, etc.
+ # Match: ragfs_python.cpython-312-darwin.so, ragfs_python.abi3.so, ragfs_python.cp312-win_amd64.pyd, etc.
if basename.startswith("ragfs_python") and (
basename.endswith(".so") or basename.endswith(".pyd")
):