From fa6c3068c003d9541d1e6ca701620f26de54c190 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 8 Dec 2024 18:12:30 -0800 Subject: [PATCH] refactor: simplify pip install command by using sys.executable directly --- aider/utils.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index 9748b73e1..3169bf08e 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -194,25 +194,9 @@ def split_chat_history_markdown(text, include_tool=False): return messages -# Copied from pip, MIT license -# https://github.com/pypa/pip/blob/b989e6ef04810bbd4033a3683020bd4ddcbdb627/src/pip/_internal/utils/entrypoints.py#L73 -def get_best_invocation_for_this_python() -> str: - """Try to figure out the best way to invoke the current Python.""" - exe = sys.executable - exe_name = os.path.basename(exe) - - # Try to use the basename, if it's the first executable. - found_executable = shutil.which(exe_name) - if found_executable and os.path.samefile(found_executable, exe): - return exe_name - - # Use the full executable name, because we couldn't find something simpler. - return exe - - def get_pip_install(args): cmd = [ - get_best_invocation_for_this_python(), + sys.executable, "-m", "pip", "install",