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

Method _build_ov_cli_artifact_impl

setup.py:189–259  ·  view source on GitHub ↗

Implement ov CLI building without final artifact checks.

(self, ov_cli_dir, binary_name, ov_target_binary)

Source from the content-addressed store, hash-verified

187 )
188
189 def _build_ov_cli_artifact_impl(self, ov_cli_dir, binary_name, ov_target_binary):
190 """Implement ov CLI building without final artifact checks."""
191
192 prebuilt_dir = os.environ.get("OV_PREBUILT_BIN_DIR")
193 if prebuilt_dir:
194 src_bin = Path(prebuilt_dir).resolve() / binary_name
195 if src_bin.exists():
196 self._copy_artifact(src_bin, ov_target_binary)
197 return
198
199 if os.environ.get("OV_SKIP_OV_BUILD") == "1":
200 if ov_target_binary.exists():
201 print("[OK] Skipping ov CLI build, using existing binary")
202 return
203 print("[Warning] OV_SKIP_OV_BUILD=1 but binary is missing. Will try to build.")
204
205 if ov_cli_dir.exists() and shutil.which("cargo"):
206 print("Building ov CLI from source...")
207 try:
208 env = _sanitize_native_build_env(os.environ.copy())
209 env["OPENVIKING_VERSION"] = resolve_openviking_version(
210 env=env, project_root=SETUP_DIR
211 )
212 build_args = ["cargo", "build", "--release"]
213 target = env.get("CARGO_BUILD_TARGET")
214 if target:
215 print(f"Cross-compiling with CARGO_BUILD_TARGET={target}")
216 build_args.extend(["--target", target])
217
218 result = subprocess.run(
219 build_args,
220 cwd=str(ov_cli_dir),
221 env=env,
222 check=True,
223 stdout=subprocess.PIPE,
224 stderr=subprocess.PIPE,
225 )
226 if result.stdout:
227 print(f"Build stdout: {result.stdout.decode('utf-8', errors='replace')}")
228 if result.stderr:
229 print(f"Build stderr: {result.stderr.decode('utf-8', errors='replace')}")
230
231 cargo_target_dir = self._resolve_cargo_target_dir(ov_cli_dir, env)
232 if target:
233 built_bin = cargo_target_dir / target / "release" / binary_name
234 else:
235 built_bin = cargo_target_dir / "release" / binary_name
236
237 self._require_artifact(built_bin, binary_name, "ov CLI build")
238 self._copy_artifact(built_bin, ov_target_binary)
239 print("[OK] ov CLI built successfully from source")
240 except Exception as exc:
241 error_msg = f"Failed to build ov CLI from source: {exc}"
242 if isinstance(exc, subprocess.CalledProcessError):
243 if exc.stdout:
244 error_msg += (
245 f"\nBuild stdout:\n{exc.stdout.decode('utf-8', errors='replace')}"
246 )

Callers 1

build_ov_cli_artifactMethod · 0.95

Calls 11

_copy_artifactMethod · 0.95
_require_artifactMethod · 0.95
strFunction · 0.50
getMethod · 0.45
resolveMethod · 0.45
existsMethod · 0.45
extendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected