lol
0
fork

Configure Feed

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

Merge pull request #198802 from delroth/relax-deps-hook-regexp

pythonRelaxDepsHook: improve Requires-Dist parsing

authored by

Pierre Bourdon and committed by
GitHub
4fe74d52 d3f4f677

+20 -2
+20 -2
pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
··· 22 22 # # pythonRemoveDeps = true; 23 23 # … 24 24 # } 25 + # 26 + # IMPLEMENTATION NOTES: 27 + # 28 + # The "Requires-Dist" dependency specification format is described in PEP 508. 29 + # Examples that the regular expressions in this hook needs to support: 30 + # 31 + # Requires-Dist: foo 32 + # -> foo 33 + # Requires-Dist: foo[optional] 34 + # -> foo[optional] 35 + # Requires-Dist: foo[optional]~=1.2.3 36 + # -> foo[optional] 37 + # Requires-Dist: foo[optional, xyz] (~=1.2.3) 38 + # -> foo[optional, xyz] 39 + # Requires-Dist: foo[optional]~=1.2.3 ; os_name = "posix" 40 + # -> foo[optional] ; os_name = "posix" 41 + # 42 + # Currently unsupported: URL specs (foo @ https://example.com/a.zip). 25 43 26 44 _pythonRelaxDeps() { 27 45 local -r metadata_file="$1" ··· 30 48 return 31 49 elif [[ "$pythonRelaxDeps" == 1 ]]; then 32 50 sed -i "$metadata_file" -r \ 33 - -e 's/(Requires-Dist: \S*) \(.*\)/\1/' 51 + -e 's/(Requires-Dist: [a-zA-Z0-9_.-]+\s*(\[[^]]+\])?)[^;]*(;.*)?/\1\3/' 34 52 else 35 53 for dep in $pythonRelaxDeps; do 36 54 sed -i "$metadata_file" -r \ 37 - -e "s/(Requires-Dist: $dep) \(.*\)/\1/" 55 + -e "s/(Requires-Dist: $dep\s*(\[[^]]+\])?)[^;]*(;.*)?/\1\3/" 38 56 done 39 57 fi 40 58 }