MCPcopy
hub / github.com/volcengine/OpenViking / build_ragfs_python_artifact

Method build_ragfs_python_artifact

setup.py:261–386  ·  view source on GitHub ↗

Build ragfs-python (Rust RAGFS binding) via maturin and copy the native extension into ``openviking/lib/`` so it ships inside the openviking wheel.

(self)

Source from the content-addressed store, hash-verified

259 print("[Warning] Cargo not found. Cannot build ov CLI from source.")
260
261 def build_ragfs_python_artifact(self):
262 """Build ragfs-python (Rust RAGFS binding) via maturin and copy the native
263 extension into ``openviking/lib/`` so it ships inside the openviking wheel.
264 """
265 require_ragfs_artifact = self._should_require_ragfs_artifact()
266 ragfs_python_dir = Path("crates/ragfs-python").resolve()
267 ragfs_lib_dir = Path("openviking/lib").resolve()
268
269 if not ragfs_python_dir.exists():
270 message = "ragfs-python source directory not found."
271 if require_ragfs_artifact:
272 raise RuntimeError(message)
273 print(f"[Info] {message} Skipping.")
274 return
275
276 if os.environ.get("OV_SKIP_RAGFS_BUILD") == "1":
277 message = "Skipping ragfs-python build (OV_SKIP_RAGFS_BUILD=1)"
278 if require_ragfs_artifact:
279 raise RuntimeError(f"{message} is incompatible with required wheel artifacts.")
280 print(f"[OK] {message}")
281 return
282
283 if importlib.util.find_spec("maturin") is None:
284 message = (
285 "maturin not found. ragfs-python (Rust binding) will not be built.\n"
286 " Install maturin to enable: pip install maturin"
287 )
288 if require_ragfs_artifact:
289 raise RuntimeError(message)
290 print(f"[SKIP] {message}")
291 return
292
293 import tempfile
294 import zipfile
295
296 with tempfile.TemporaryDirectory() as tmpdir:
297 try:
298 print("Building ragfs-python (Rust RAGFS binding) via maturin...")
299 env = _sanitize_native_build_env(os.environ.copy())
300 build_args = [
301 sys.executable,
302 "-m",
303 "maturin",
304 "build",
305 "--release",
306 "--out",
307 tmpdir,
308 ]
309 # Respect CARGO_BUILD_TARGET for cross-compilation
310 target = env.get("CARGO_BUILD_TARGET")
311 if target:
312 build_args.extend(["--target", target])
313
314 result = subprocess.run(
315 build_args,
316 cwd=str(ragfs_python_dir),
317 env=env,
318 check=True,

Callers 1

runMethod · 0.95

Calls 15

strFunction · 0.50
resolveMethod · 0.45
existsMethod · 0.45
getMethod · 0.45
extendMethod · 0.45
runMethod · 0.45
globMethod · 0.45
mkdirMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected