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

Function get_lib_paths

scripts/update_lib/deps.py:886–915  ·  view source on GitHub ↗

Get all library paths for a module. Args: name: Module name (e.g., "datetime", "libregrtest") cpython_prefix: CPython directory prefix Returns: Tuple of paths to copy

(name: str, cpython_prefix: str)

Source from the content-addressed store, hash-verified

884
885@functools.cache
886def get_lib_paths(name: str, cpython_prefix: str) -> tuple[pathlib.Path, ...]:
887 """Get all library paths for a module.
888
889 Args:
890 name: Module name (e.g., "datetime", "libregrtest")
891 cpython_prefix: CPython directory prefix
892
893 Returns:
894 Tuple of paths to copy
895 """
896 dep_info = DEPENDENCIES.get(name, {})
897
898 # Get main lib path (override or default)
899 if "lib" in dep_info:
900 paths = [construct_lib_path(cpython_prefix, p) for p in dep_info["lib"]]
901 else:
902 # Default: try file first, then directory
903 paths = [resolve_module_path(name, cpython_prefix, prefer="file")]
904
905 # Add hard_deps from DEPENDENCIES
906 for dep in dep_info.get("hard_deps", []):
907 paths.append(construct_lib_path(cpython_prefix, dep))
908
909 # Auto-detect _py{module}.py or _py_{module}.py patterns
910 for pattern in [f"_py{name}.py", f"_py_{name}.py"]:
911 auto_path = construct_lib_path(cpython_prefix, pattern)
912 if auto_path.exists() and auto_path not in paths:
913 paths.append(auto_path)
914
915 return tuple(paths)
916
917
918def get_all_hard_deps(name: str, cpython_prefix: str) -> list[str]:

Callers 11

copy_libFunction · 0.90
format_deps_treeFunction · 0.90
format_depsFunction · 0.90
_resolve_module_nameFunction · 0.90
test_default_fileMethod · 0.90
get_all_importsFunction · 0.85
is_up_to_dateFunction · 0.85
get_module_last_updatedFunction · 0.85
get_module_diff_statFunction · 0.85

Calls 5

construct_lib_pathFunction · 0.90
resolve_module_pathFunction · 0.90
getMethod · 0.45
appendMethod · 0.45
existsMethod · 0.45

Tested by 3

test_default_fileMethod · 0.72