Skip to content

Commit 8c6547e

Browse files
s0undt3chCh3LLgarethgreenaway
authored
Work around pypa/pip#9450 (#60625)
* Also pin the ``pip`` upgrade to be ``<21.2`` * Work around pypa/pip#9450 See pypa/pip#10212 Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org>
1 parent 29dc3e0 commit 8c6547e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

salt/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,6 @@ def __define_global_system_encoding_variable__():
119119

120120
# This is now garbage collectable
121121
del __define_global_system_encoding_variable__
122+
123+
# Import Salt's logging machinery
124+
import salt._logging.impl # isort:skip pylint: disable=unused-import

salt/_logging/impl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,22 @@ def makeRecord(
385385
# Override the python's logging logger class as soon as this module is imported
386386
if logging.getLoggerClass() is not SaltLoggingClass:
387387

388+
# Import pip._internal which itself will install it's own custom logging handler
389+
# we want to override that handler with ours
390+
try:
391+
import pip._internal.utils._log as pip_log_module # pylint: disable=no-name-in-module,import-error
392+
except ImportError:
393+
pip_log_module = None
394+
388395
logging.setLoggerClass(SaltLoggingClass)
389396
logging.addLevelName(QUIET, "QUIET")
390397
logging.addLevelName(PROFILE, "PROFILE")
391398
logging.addLevelName(TRACE, "TRACE")
392399
logging.addLevelName(GARBAGE, "GARBAGE")
400+
if pip_log_module is not None:
401+
# Let's make newer versions of pip work by patching SaltLoggingClass to
402+
# add a verbose method which is what pip expects
403+
SaltLoggingClass.verbose = SaltLoggingClass.debug
393404

394405
# ----- REMOVE ON REFACTORING COMPLETE -------------------------------------------------------------------------->
395406
if not logging.root.handlers:

0 commit comments

Comments
 (0)