MCPcopy Index your code
hub / github.com/RustPython/RustPython / detect_build_directory

Function detect_build_directory

crates/vm/src/getpath.rs:225–240  ·  view source on GitHub ↗

Detect if running from a build directory

(exe_dir: &Option<PathBuf>)

Source from the content-addressed store, hash-verified

223
224/// Detect if running from a build directory
225fn detect_build_directory(exe_dir: &Option<PathBuf>) -> Option<PathBuf> {
226 let dir = exe_dir.as_ref()?;
227
228 // Check for pybuilddir.txt (indicates build directory)
229 if dir.join(platform::BUILDDIR_TXT).exists() {
230 return Some(dir.clone());
231 }
232
233 // Check for Modules/Setup.local (build landmark)
234 if dir.join(platform::BUILD_LANDMARK).exists() {
235 return Some(dir.clone());
236 }
237
238 // Search up for Lib/os.py (build stdlib landmark)
239 search_up_file(dir, &[platform::BUILDSTDLIB_LANDMARK])
240}
241
242/// Calculate prefix by searching for landmarks
243fn calculate_prefix(exe_dir: &Option<PathBuf>, build_prefix: &Option<PathBuf>) -> String {

Callers 1

init_path_configFunction · 0.85

Calls 6

search_up_fileFunction · 0.85
SomeClass · 0.50
as_refMethod · 0.45
existsMethod · 0.45
joinMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected