Skip to content

Commit

Permalink
Eagerly normalize the cache directory
Browse files Browse the repository at this point in the history
Fixes pypa#7541
  • Loading branch information
sbidoul committed Jan 2, 2020
1 parent 68e49b9 commit 319a256
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.logging import BrokenStdoutLoggingError, setup_logging
from pip._internal.utils.misc import get_prog
from pip._internal.utils.misc import get_prog, normalize_path
from pip._internal.utils.temp_dir import global_tempdir_manager
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import running_under_virtualenv
Expand Down Expand Up @@ -170,6 +170,7 @@ def _main(self, args):
sys.exit(VIRTUALENV_NOT_FOUND)

if options.cache_dir:
options.cache_dir = normalize_path(options.cache_dir)
if not check_path_owner(options.cache_dir):
logger.warning(
"The directory '%s' or its parent directory is not owned "
Expand Down
2 changes: 2 additions & 0 deletions src/pip/_internal/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def check_path_owner(path):
if sys.platform == "win32" or not hasattr(os, "geteuid"):
return True

assert os.path.isabs(path)

previous = None
while path != previous:
if os.path.lexists(path):
Expand Down

0 comments on commit 319a256

Please sign in to comment.