lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

python/hooks: restore catchConflictHook for python<3.10

By restoring and diverting to the old version.

Previously the newer language features and use of more modern stdlib
imports broke the hook on Python<3.10.

+39 -2
+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