Skip to content

Commit

Permalink
Rework command-building code to clean it up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dos Moonen committed Aug 10, 2023
1 parent a0fff25 commit 8c70e41
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/pipx/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,15 @@ def install_package(
):
# do not use -q with `pip install` so subprocess_post_check_pip_errors
# has more information to analyze in case of failure.
cmd = (
[str(self.python_path), "-m", "pip", "--no-input", "install"]
+ pip_args
+ [package_or_url]
)
cmd = [
str(self.python_path),
"-m",
"pip",
"--no-input",
"install",
*pip_args,
package_or_url,
]
# no logging because any errors will be specially logged by
# subprocess_post_check_handle_pip_error()
pip_process = run_subprocess(cmd, log_stdout=False, log_stderr=False)
Expand Down Expand Up @@ -284,11 +288,15 @@ def install_unmanaged_packages(
with animate(f"installing {', '.join(requirements)}", self.do_animation):
# do not use -q with `pip install` so subprocess_post_check_pip_errors
# has more information to analyze in case of failure.
cmd = (
[str(self.python_path), "-m", "pip", "--no-input", "install"]
+ pip_args
+ requirements
)
cmd = [
str(self.python_path),
"-m",
"pip",
"--no-input",
"install",
*pip_args,
*requirements,
]
# no logging because any errors will be specially logged by
# subprocess_post_check_handle_pip_error()
pip_process = run_subprocess(cmd, log_stdout=False, log_stderr=False)
Expand All @@ -301,11 +309,13 @@ def install_package_no_deps(self, package_or_url: str, pip_args: List[str]) -> s
f"determining package name from {package_or_url!r}", self.do_animation
):
old_package_set = self.list_installed_packages()
cmd = (
["--no-input", "install", "--no-dependencies"]
+ pip_args
+ [package_or_url]
)
cmd = [
"--no-input",
"install",
"--no-dependencies",
*pip_args,
package_or_url,
]
pip_process = self._run_pip(cmd)
subprocess_post_check(pip_process, raise_error=False)
if pip_process.returncode:
Expand Down

0 comments on commit 8c70e41

Please sign in to comment.