From ec20d5b218dd92537d7e528ae00972bb0802e82d Mon Sep 17 00:00:00 2001 From: Zachary Spector Date: Mon, 12 Aug 2024 01:35:25 +1200 Subject: [PATCH 1/2] Quote path to pip executable This lets us call pip if it's in a virtualenv with a name that contains spaces. --- src/pipupgrade/_pip.py | 4 ++-- src/pipupgrade/commands/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pipupgrade/_pip.py b/src/pipupgrade/_pip.py index a765db7..2c3758d 100644 --- a/src/pipupgrade/_pip.py +++ b/src/pipupgrade/_pip.py @@ -43,11 +43,11 @@ def _get_pip_executable(multiple = False): exec_ = which(pip_) if exec_: if not multiple: - return exec_ + return '"' + exec_ + '"' else: exec_ = osp.realpath(exec_) if exec_ not in execs: - execs.append(exec_) + execs.append('"' + exec_ + '"') if not execs: # pragma: no cover raise ValueError("pip executable not found.") diff --git a/src/pipupgrade/commands/__init__.py b/src/pipupgrade/commands/__init__.py index 0bcd1ad..4e2b53a 100644 --- a/src/pipupgrade/commands/__init__.py +++ b/src/pipupgrade/commands/__init__.py @@ -144,7 +144,7 @@ def _command(*args, **kwargs): cli.echo(cli_format("Checking...", cli.YELLOW), file = file_) pip_path = a.pip_path or [ ] - pip_path = [which(p) for p in pip_path] or _pip._PIP_EXECUTABLES + pip_path = ['"' + which(p) + '"' for p in pip_path] or _pip._PIP_EXECUTABLES logger.info("`pip` executables found: %s" % pip_path) From 154cc766b447859e7e119c60077b25721bbad24b Mon Sep 17 00:00:00 2001 From: Zachary Spector Date: Mon, 12 Aug 2024 01:57:26 +1200 Subject: [PATCH 2/2] Fix pip executables showing up more than once --- src/pipupgrade/_pip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pipupgrade/_pip.py b/src/pipupgrade/_pip.py index 2c3758d..23f100e 100644 --- a/src/pipupgrade/_pip.py +++ b/src/pipupgrade/_pip.py @@ -45,9 +45,9 @@ def _get_pip_executable(multiple = False): if not multiple: return '"' + exec_ + '"' else: - exec_ = osp.realpath(exec_) + exec_ = '"' + osp.realpath(exec_) + '"' if exec_ not in execs: - execs.append('"' + exec_ + '"') + execs.append(exec_) if not execs: # pragma: no cover raise ValueError("pip executable not found.")