Check if a module is up-to-date by comparing files. Args: name: Module name cpython_prefix: CPython directory prefix lib_prefix: Local Lib directory prefix Returns: True if all files match, False otherwise
(name: str, cpython_prefix: str, lib_prefix: str)
| 1047 | |
| 1048 | @functools.cache |
| 1049 | def is_up_to_date(name: str, cpython_prefix: str, lib_prefix: str) -> bool: |
| 1050 | """Check if a module is up-to-date by comparing files. |
| 1051 | |
| 1052 | Args: |
| 1053 | name: Module name |
| 1054 | cpython_prefix: CPython directory prefix |
| 1055 | lib_prefix: Local Lib directory prefix |
| 1056 | |
| 1057 | Returns: |
| 1058 | True if all files match, False otherwise |
| 1059 | """ |
| 1060 | lib_paths = get_lib_paths(name, cpython_prefix) |
| 1061 | |
| 1062 | found_any = False |
| 1063 | for cpython_path in lib_paths: |
| 1064 | if not cpython_path.exists(): |
| 1065 | continue |
| 1066 | |
| 1067 | found_any = True |
| 1068 | |
| 1069 | # Convert cpython path to local path |
| 1070 | # cpython/Lib/foo.py -> Lib/foo.py |
| 1071 | rel_path = cpython_path.relative_to(cpython_prefix) |
| 1072 | local_path = pathlib.Path(lib_prefix) / rel_path.relative_to("Lib") |
| 1073 | |
| 1074 | if not compare_paths(cpython_path, local_path): |
| 1075 | return False |
| 1076 | |
| 1077 | if not found_any: |
| 1078 | dep_info = DEPENDENCIES.get(name, {}) |
| 1079 | if dep_info.get("lib") == []: |
| 1080 | return True |
| 1081 | return found_any |
| 1082 | |
| 1083 | |
| 1084 | def _count_file_diff(file_a: pathlib.Path, file_b: pathlib.Path) -> int: |
no test coverage detected