MCPcopy
hub / github.com/pathwaycom/pathway / cargo_build

Function cargo_build

python/pathway/_engine_finder.py:42–82  ·  view source on GitHub ↗
(manifest_dir: Path)

Source from the content-addressed store, hash-verified

40
41
42def cargo_build(manifest_dir: Path) -> Path:
43 assert not (manifest_dir / "__init__.py").exists()
44 manifest_file = manifest_dir / "Cargo.toml"
45 assert manifest_file.exists()
46 profile = environ.get(PROFILE_ENV_VAR, DEFAULT_PROFILE)
47 quiet = environ.get(QUIET_ENV_VAR, "0").lower() in ("1", "true", "yes")
48 features = environ.get(FEATURES_ENV_VAR)
49 args = [
50 "cargo",
51 "--locked",
52 "build",
53 "--lib",
54 "--message-format=json-render-diagnostics",
55 f"--profile={profile}",
56 ]
57 if quiet:
58 args += ["--quiet"]
59 if features:
60 args += ["--features", features]
61 cargo = subprocess.run(
62 args,
63 stdin=subprocess.DEVNULL,
64 stdout=subprocess.PIPE,
65 cwd=manifest_dir,
66 text=True,
67 check=True,
68 )
69 module_candidates = []
70 for line in cargo.stdout.splitlines():
71 data = json.loads(line)
72 if data["reason"] != "compiler-artifact":
73 continue
74 if data["target"]["name"] != RUST_CRATE:
75 continue
76 for filename in data["filenames"]:
77 path = Path(filename)
78 if path.suffix not in EXTENSION_SUFFIXES:
79 continue
80 module_candidates.append(path)
81 assert len(module_candidates) == 1
82 return module_candidates[0]
83
84
85sys.meta_path.append(MagicCargoFinder())

Callers 1

find_specMethod · 0.85

Calls 4

lowerMethod · 0.80
getMethod · 0.45
runMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected