Get soft dependencies by parsing imports from library file. Args: name: Module name cpython_prefix: CPython directory prefix Returns: Frozenset of imported stdlib module names (those that exist in cpython/Lib/)
(name: str, cpython_prefix: str)
| 987 | |
| 988 | @functools.cache |
| 989 | def get_soft_deps(name: str, cpython_prefix: str) -> frozenset[str]: |
| 990 | """Get soft dependencies by parsing imports from library file. |
| 991 | |
| 992 | Args: |
| 993 | name: Module name |
| 994 | cpython_prefix: CPython directory prefix |
| 995 | |
| 996 | Returns: |
| 997 | Frozenset of imported stdlib module names (those that exist in cpython/Lib/) |
| 998 | """ |
| 999 | all_imports = get_all_imports(name, cpython_prefix) |
| 1000 | |
| 1001 | # Filter: only include modules that exist in cpython/Lib/ |
| 1002 | stdlib_deps = set() |
| 1003 | for imp in all_imports: |
| 1004 | module_path = resolve_module_path(imp, cpython_prefix) |
| 1005 | if module_path.exists(): |
| 1006 | stdlib_deps.add(imp) |
| 1007 | |
| 1008 | return frozenset(stdlib_deps) |
| 1009 | |
| 1010 | |
| 1011 | @functools.cache |