···11+import pkg_resources
22+import collections
33+import sys
44+55+do_abort = False
66+packages = collections.defaultdict(list)
77+88+for f in sys.path:
99+ for req in pkg_resources.find_distributions(f):
1010+ if req not in packages[req.project_name]:
1111+ # some exceptions inside buildPythonPackage
1212+ if req.project_name in ['setuptools', 'pip', 'wheel']:
1313+ continue
1414+ packages[req.project_name].append(req)
1515+1616+1717+for name, duplicates in packages.items():
1818+ if len(duplicates) > 1:
1919+ do_abort = True
2020+ print("Found duplicated packages in closure for dependency '{}': ".format(name))
2121+ for dup in duplicates:
2222+ print(" " + repr(dup))
2323+2424+if do_abort:
2525+ print("")
2626+ print(
2727+ 'Package duplicates found in closure, see above. Usually this '
2828+ 'happens if two packages depend on different version '
2929+ 'of the same dependency.')
3030+ sys.exit(1)
···5757# Raise an error if two packages are installed with the same name
5858# TODO: For cross we probably need a different PYTHONPATH, or not
5959# add the runtime deps until after buildPhase.
6060-# FIXME: disabled for Python 2 because broken
6161-, catchConflicts ? false
6060+, catchConflicts ? (python.stdenv.hostPlatform == python.stdenv.buildPlatform)
62616362# Additional arguments to pass to the makeWrapper function, which wraps
6463# generated binaries.