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

Function copy_lib

scripts/update_lib/cmd_copy_lib.py:49–83  ·  view source on GitHub ↗

Copy library file or directory from CPython. Also copies additional files if defined in DEPENDENCIES table. Args: src_path: Source path (e.g., cpython/Lib/dataclasses.py or cpython/Lib/json) verbose: Print progress messages

(
    src_path: pathlib.Path,
    verbose: bool = True,
)

Source from the content-addressed store, hash-verified

47
48
49def copy_lib(
50 src_path: pathlib.Path,
51 verbose: bool = True,
52) -> None:
53 """
54 Copy library file or directory from CPython.
55
56 Also copies additional files if defined in DEPENDENCIES table.
57
58 Args:
59 src_path: Source path (e.g., cpython/Lib/dataclasses.py or cpython/Lib/json)
60 verbose: Print progress messages
61 """
62 from update_lib.deps import get_lib_paths
63 from update_lib.file_utils import parse_lib_path
64
65 # Extract module name and cpython prefix from path
66 path_str = str(src_path).replace("\\", "/")
67 if "/Lib/" not in path_str:
68 raise ValueError(f"Path must contain '/Lib/' (got: {src_path})")
69
70 cpython_prefix, after_lib = path_str.split("/Lib/", 1)
71 # Get module name (first component, without .py)
72 name = after_lib.split("/")[0]
73 if name.endswith(".py"):
74 name = name[:-3]
75
76 # Get all paths to copy from DEPENDENCIES table
77 all_src_paths = get_lib_paths(name, cpython_prefix)
78
79 # Copy each file
80 for src in all_src_paths:
81 if src.exists():
82 lib_path = parse_lib_path(src)
83 _copy_single(src, lib_path, verbose)
84
85
86def main(argv: list[str] | None = None) -> int:

Callers 3

mainFunction · 0.90
mainFunction · 0.85

Calls 8

get_lib_pathsFunction · 0.90
parse_lib_pathFunction · 0.90
strFunction · 0.85
_copy_singleFunction · 0.85
replaceMethod · 0.45
splitMethod · 0.45
endswithMethod · 0.45
existsMethod · 0.45

Tested by 1