lol

Merge pull request #267669 from mweinelt/catch-python2-conflicts

python/hooks: restore catchConflictHook for python<3.10

authored by

Martin Weinelt and committed by
GitHub
2203d3bf e7e5233f

+40 -4
+30
pkgs/development/interpreters/python/catch_conflicts/catch_conflicts_py2.py
··· 1 + import pkg_resources 2 + import collections 3 + import sys 4 + 5 + do_abort = False 6 + packages = collections.defaultdict(list) 7 + 8 + for f in sys.path: 9 + for req in pkg_resources.find_distributions(f): 10 + if req not in packages[req.project_name]: 11 + # some exceptions inside buildPythonPackage 12 + if req.project_name in ['setuptools', 'pip', 'wheel']: 13 + continue 14 + packages[req.project_name].append(req) 15 + 16 + 17 + for name, duplicates in packages.items(): 18 + if len(duplicates) > 1: 19 + do_abort = True 20 + print("Found duplicated packages in closure for dependency '{}': ".format(name)) 21 + for dup in duplicates: 22 + print(" " + repr(dup)) 23 + 24 + if do_abort: 25 + print("") 26 + print( 27 + 'Package duplicates found in closure, see above. Usually this ' 28 + 'happens if two packages depend on different version ' 29 + 'of the same dependency.') 30 + sys.exit(1)
+9 -2
pkgs/development/interpreters/python/hooks/default.nix
··· 106 106 pythonCatchConflictsHook = callPackage ({ makePythonHook, setuptools }: 107 107 makePythonHook { 108 108 name = "python-catch-conflicts-hook"; 109 - substitutions = { 109 + substitutions = let 110 + useLegacyHook = lib.versionOlder python.version "3.10"; 111 + in { 110 112 inherit pythonInterpreter pythonSitePackages; 111 - catchConflicts=../catch_conflicts/catch_conflicts.py; 113 + catchConflicts = if useLegacyHook then 114 + ../catch_conflicts/catch_conflicts_py2.py 115 + else 116 + ../catch_conflicts/catch_conflicts.py; 117 + } // lib.optionalAttrs useLegacyHook { 118 + inherit setuptools; 112 119 }; 113 120 } ./python-catch-conflicts-hook.sh) {}; 114 121
+1 -2
pkgs/development/interpreters/python/python2/mk-python-derivation.nix
··· 57 57 # Raise an error if two packages are installed with the same name 58 58 # TODO: For cross we probably need a different PYTHONPATH, or not 59 59 # add the runtime deps until after buildPhase. 60 - # FIXME: disabled for Python 2 because broken 61 - , catchConflicts ? false 60 + , catchConflicts ? (python.stdenv.hostPlatform == python.stdenv.buildPlatform) 62 61 63 62 # Additional arguments to pass to the makeWrapper function, which wraps 64 63 # generated binaries.