move the check to create_os_error_message

This commit is contained in:
OBITORASU 2021-06-09 01:05:54 +05:30
parent 67dcdf5e11
commit 560d2e97ae
1 changed files with 13 additions and 10 deletions

View File

@ -441,16 +441,6 @@ class InstallCommand(RequirementCommand):
message = create_os_error_message(
error, show_traceback, options.use_user_site,
)
if (WINDOWS and error.errno == errno.ENOENT and error.filename and
len(error.filename) > 260):
logger.warning(
'The following error can potentially be caused '
'because Long Paths is disabled on your system. '
'Please set LongPathsEnabled to 1 in the '
'registry and try again. For further instructions '
'please refer to the documentation: '
'https://pip.pypa.io/warnings/enable-long-paths'
)
logger.error(message, exc_info=show_traceback) # noqa
return ERROR
@ -748,4 +738,17 @@ def create_os_error_message(error, show_traceback, using_user_site):
parts.append(permissions_part)
parts.append(".\n")
# Suggest the user to enable Long Paths if path length is
# more than 260
if (WINDOWS and error.errno == errno.ENOENT and error.filename and
len(error.filename) > 260):
parts.append(
"The following error can potentially be caused "
"because Long Paths is disabled on your system. "
"Please set LongPathsEnabled to 1 in the "
"registry and try again. For further instructions "
"please refer to the documentation: "
"https://pip.pypa.io/warnings/enable-long-paths"
)
return "".join(parts).strip() + "\n"