Skip to content

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

fix(ragfs): load Windows abi3 pyd artifact (#1801)

Qin Haojie964998dacad5
diff --git a/openviking/pyagfs/__init__.py b/openviking/pyagfs/__init__.py
index 565796b5f..814f15e9a 100644
--- a/openviking/pyagfs/__init__.py
+++ b/openviking/pyagfs/__init__.py
@@ -50,12 +50,15 @@ def _find_ragfs_so():
try:
# The ragfs-python crate is built with PyO3's stable ABI. Do not load
# cpython-specific artifacts from older source-checkout builds.
- 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)
+ for filename in ("ragfs_python.pyd", "ragfs_python.abi3.pyd"):
+ exact_path = _LIB_DIR / filename
+ if exact_path.exists():
+ return str(exact_path)
+ else:
+ abi3_exact = _LIB_DIR / "ragfs_python.abi3.so"
+ if abi3_exact.exists():
+ return str(abi3_exact)
# Glob fallback handles platform-tagged abi3 artifacts if any.
for pattern in ("ragfs_python.abi3.*",):
matches = glob.glob(str(_LIB_DIR / pattern))
diff --git a/setup.py b/setup.py
index f24c3024e..abfbaa8f6 100644
--- a/setup.py
+++ b/setup.py
@@ -344,9 +344,14 @@ class OpenVikingBuildExt(build_ext):
with zipfile.ZipFile(str(whl_files[0])) as zf:
for name in zf.namelist():
basename = Path(name).name
- if basename.startswith("ragfs_python.abi3.") and (
- basename.endswith(".so") or basename.endswith(".pyd")
- ):
+ is_ragfs_extension = (
+ basename == "ragfs_python.pyd"
+ or (
+ basename.startswith("ragfs_python.abi3.")
+ and basename.endswith((".so", ".pyd"))
+ )
+ )
+ if is_ragfs_extension:
target_path = ragfs_lib_dir / basename
with zf.open(name) as src, open(target_path, "wb") as dst:
dst.write(src.read())
@@ -357,7 +362,7 @@ class OpenVikingBuildExt(build_ext):
break
if not extracted:
- message = "Could not find ragfs_python abi3 .so/.pyd in built wheel."
+ message = "Could not find ragfs_python stable-ABI native extension in built wheel."
if require_ragfs_artifact:
raise RuntimeError(message)
print(f"[Warning] {message}")
diff --git a/tests/misc/test_abi3_packaging_config.py b/tests/misc/test_abi3_packaging_config.py
index e60a7c056..cb0d57112 100644
--- a/tests/misc/test_abi3_packaging_config.py
+++ b/tests/misc/test_abi3_packaging_config.py
@@ -83,6 +83,14 @@ def test_build_workflow_smoke_tests_linux_and_macos_ragfs_binding_import():
assert "Loaded RAGFS binding client" in build_workflow
+def test_setup_extracts_windows_ragfs_python_pyd_from_maturin_wheel():
+ setup_py = _read_text("setup.py")
+
+ assert 'basename == "ragfs_python.pyd"' in setup_py
+ assert 'basename.startswith("ragfs_python.abi3.")' in setup_py
+ assert "stable-ABI native extension" in setup_py
+
+
def test_windows_abi3_backend_uses_stable_python_linkage():
setup_py = _read_text("setup.py")
src_cmake = _read_text("src/CMakeLists.txt")
diff --git a/tests/misc/test_pyagfs_loader.py b/tests/misc/test_pyagfs_loader.py
index c13f9a525..3072f08f1 100644
--- a/tests/misc/test_pyagfs_loader.py
+++ b/tests/misc/test_pyagfs_loader.py
@@ -22,3 +22,17 @@ def test_pyagfs_loader_ignores_cpython_specific_artifact(monkeypatch, tmp_path:
monkeypatch.setattr(pyagfs, "_LIB_DIR", tmp_path)
assert pyagfs._find_ragfs_so() is None
+
+
+def test_pyagfs_loader_finds_windows_maturin_abi3_pyd(monkeypatch, tmp_path: Path):
+ import openviking.pyagfs as pyagfs
+
+ cpython_artifact = tmp_path / "ragfs_python.cp310-win_amd64.pyd"
+ abi3_artifact = tmp_path / "ragfs_python.pyd"
+ cpython_artifact.write_bytes(b"old")
+ abi3_artifact.write_bytes(b"new")
+
+ monkeypatch.setattr(pyagfs, "_LIB_DIR", tmp_path)
+ monkeypatch.setattr(pyagfs.sys, "platform", "win32")
+
+ assert pyagfs._find_ragfs_so() == str(abi3_artifact)