Return a mapping of top-level packages to their distributions. >>> import collections.abc >>> pkgs = packages_distributions() >>> all(isinstance(dist, collections.abc.Sequence) for dist in pkgs.values()) True
()
| 1145 | |
| 1146 | |
| 1147 | def packages_distributions() -> Mapping[str, list[str]]: |
| 1148 | """ |
| 1149 | Return a mapping of top-level packages to their |
| 1150 | distributions. |
| 1151 | |
| 1152 | >>> import collections.abc |
| 1153 | >>> pkgs = packages_distributions() |
| 1154 | >>> all(isinstance(dist, collections.abc.Sequence) for dist in pkgs.values()) |
| 1155 | True |
| 1156 | """ |
| 1157 | pkg_to_dist = collections.defaultdict(list) |
| 1158 | for dist in distributions(): |
| 1159 | for pkg in _top_level_declared(dist) or _top_level_inferred(dist): |
| 1160 | pkg_to_dist[pkg].append(dist.metadata['Name']) |
| 1161 | return dict(pkg_to_dist) |
| 1162 | |
| 1163 | |
| 1164 | def _top_level_declared(dist): |
searching dependent graphs…