2015-11-18 11:46:21 +01:00
|
|
|
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]:
|
2015-11-19 09:56:11 +01:00
|
|
|
# some exceptions inside buildPythonPackage
|
2016-06-16 11:16:30 +02:00
|
|
|
if req.project_name in ['setuptools', 'pip', 'wheel']:
|
2015-11-18 11:46:21 +01:00
|
|
|
continue
|
|
|
|
packages[req.project_name].append(req)
|
|
|
|
|
|
|
|
|
2015-11-18 19:03:05 +01:00
|
|
|
for name, duplicates in packages.items():
|
2015-11-18 11:46:21 +01:00
|
|
|
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)
|