Skip to content

Commit

Permalink
Work around pypa/pip#9450
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed Jul 27, 2021
1 parent 1008aaa commit 377f7ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _upgrade_pip_setuptools_and_wheel(session):
"install",
"--progress-bar=off",
"-U",
"pip>=20.2.4,<21.2",
"pip>=20.2.4",
"setuptools!=50.*,!=51.*,!=52.*",
"wheel",
]
Expand Down
3 changes: 3 additions & 0 deletions salt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ def __define_global_system_encoding_variable__():

# This is now garbage collectable
del __define_global_system_encoding_variable__

# Import Salt's logging machinery
import salt._logging.impl # isort:skip pylint: disable=unused-import
11 changes: 11 additions & 0 deletions salt/_logging/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,22 @@ def makeRecord(
# Override the python's logging logger class as soon as this module is imported
if logging.getLoggerClass() is not SaltLoggingClass:

# Import pip._internal which itself will install it's own custom logging handler
# we want to override that handler with ours
try:
import pip._internal.utils._log as pip_log_module # pylint: disable=no-name-in-module,import-error
except ImportError:
pip_log_module = None

logging.setLoggerClass(SaltLoggingClass)
logging.addLevelName(QUIET, "QUIET")
logging.addLevelName(PROFILE, "PROFILE")
logging.addLevelName(TRACE, "TRACE")
logging.addLevelName(GARBAGE, "GARBAGE")
if pip_log_module is not None:
# Let's make newer versions of pip work by patching SaltLoggingClass to
# add a verbose method which is what pip expects
SaltLoggingClass.verbose = SaltLoggingClass.debug

# ----- REMOVE ON REFACTORING COMPLETE -------------------------------------------------------------------------->
if not logging.root.handlers:
Expand Down

0 comments on commit 377f7ba

Please sign in to comment.