Files
nixpkgs/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py
T
Martin Weinelt 646c23a2f7 buildPythonPackage: port catch-conflicts to importlib.metadata
To escape the pkg_resources API deprecation:

> catch-conflicts.py:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Also remove exceptions for the previus bootstrap packages.
2023-10-30 12:42:36 +01:00

35 lines
899 B
Python

from importlib.metadata import PathDistribution
from pathlib import Path
import collections
import sys
do_abort = False
packages = collections.defaultdict(list)
for path in sys.path:
for dist_info in Path(path).glob("*.dist-info"):
dist = PathDistribution(dist_info)
packages[dist._normalized_name].append(
f"{dist._normalized_name} {dist.version} ({dist._path})"
)
for name, duplicates in packages.items():
if len(duplicates) > 1:
do_abort = True
print("Found duplicated packages in closure for dependency '{}': ".format(name))
for duplicate in duplicates:
print(f"\t{duplicate}")
if do_abort:
print("")
print(
"Package duplicates found in closure, see above. Usually this "
"happens if two packages depend on different version "
"of the same dependency."
)
sys.exit(1)