nixpkgs/pkgs/development/python-modules/generic/do_conflict.py

30 lines
838 B
Python
Raw Normal View History

import pkg_resources
import collections
import sys
do_abort = False
packages = collections.defaultdict(list)
for f in sys.path:
for req in pkg_resources.find_distributions(f):
if req not in packages[req.project_name]:
if req.project_name == 'setuptools':
continue
packages[req.project_name].append(req)
for name, duplicates in packages.iteritems():
if len(duplicates) > 1:
do_abort = True
print("Found duplicated packages in closure for dependency '{}': ".format(name))
for dup in duplicates:
print(" " + repr(dup))
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)