From 9306254748e9fc1762e946cf7e8ace5c3f728219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Thu, 30 Jul 2020 17:34:09 +0700 Subject: [PATCH] Improve log/error messages esp. ones involve ENABLE_USER_SITE This is to be squashed with the commit above --- src/pip/_internal/commands/install.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index dfde7af107f..0050aa72d57 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -688,6 +688,7 @@ def decide_user_install( # (mismatch between user or group id and effective id) # or by an administrator. if use_user_site is not None: + # use_user_site might be passed as an int. use_user_site = bool(use_user_site) if use_user_site: logger.debug("User install by explicit request") @@ -695,19 +696,15 @@ def decide_user_install( logger.debug("Non-user install by explicit request") if use_user_site and ENABLE_USER_SITE is None: raise InstallationError( - "User site-packages are disabled " - "for security reasons or by an administrator." + "User site-packages cannot be used because " + "site.ENABLE_USER_SITE is None, which indicates " + "it was disabled for security reasons or by an administrator." ) - elif ENABLE_USER_SITE is None: + elif not ENABLE_USER_SITE: logger.debug( - "User site-packages are disabled " - "for security reasons or by an administrator." - ) - use_user_site = False - elif ENABLE_USER_SITE is False: - logger.debug( - "User site-packages are disabled by user request " - "(with 'python -s' or PYTHONNOUSERSITE)" + "User site-packages is disabled " + "because site.ENABLE_USER_SITE is %s", + ENABLE_USER_SITE, ) use_user_site = False elif root_path is not None: @@ -728,7 +725,7 @@ def decide_user_install( if virtualenv_no_global(): raise InstallationError( "Can not perform a '--user' install. " - "User site-packages are not visible in this virtualenv." + "User site-packages is not visible in this virtualenv." ) if not site_packages_writable( user=use_user_site, root=root_path, isolated=isolated_mode,