-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
pkgs/development/interpreters/python/catch_conflicts/catch_conflicts_py2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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]: | ||
# some exceptions inside buildPythonPackage | ||
if req.project_name in ['setuptools', 'pip', 'wheel']: | ||
continue | ||
packages[req.project_name].append(req) | ||
|
||
|
||
for name, duplicates in packages.items(): | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters