mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
try-except distutils config parsing
This commit is contained in:
parent
15459969b3
commit
c5f9bc5f3b
2 changed files with 13 additions and 1 deletions
1
news/8931.bugfix.rst
Normal file
1
news/8931.bugfix.rst
Normal file
|
@ -0,0 +1 @@
|
|||
Skip distutils configuration parsing on encoding errors.
|
|
@ -3,6 +3,7 @@
|
|||
# The following comment should be removed at some point in the future.
|
||||
# mypy: strict-optional=False
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from distutils.cmd import Command as DistutilsCommand
|
||||
|
@ -17,6 +18,8 @@ from pip._internal.utils.virtualenv import running_under_virtualenv
|
|||
|
||||
from .base import get_major_minor_version
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _distutils_scheme(
|
||||
dist_name: str,
|
||||
|
@ -36,7 +39,15 @@ def _distutils_scheme(
|
|||
dist_args["script_args"] = ["--no-user-cfg"]
|
||||
|
||||
d = Distribution(dist_args)
|
||||
d.parse_config_files()
|
||||
try:
|
||||
d.parse_config_files()
|
||||
except UnicodeDecodeError:
|
||||
# Typeshed does not include find_config_files() for some reason.
|
||||
paths = d.find_config_files() # type: ignore
|
||||
logger.warning(
|
||||
"Ignore distutils configs in %s due to encoding errors.",
|
||||
", ".join(os.path.basename(p) for p in paths),
|
||||
)
|
||||
obj: Optional[DistutilsCommand] = None
|
||||
obj = d.get_command_obj("install", create=True)
|
||||
assert obj is not None
|
||||
|
|
Loading…
Reference in a new issue