mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
adopt pip's get_best_invocation_for_this_python
This commit is contained in:
parent
ecf80a799d
commit
2cfdd7ab5b
1 changed files with 18 additions and 1 deletions
|
@ -2,6 +2,7 @@ import itertools
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import shlex
|
import shlex
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -193,9 +194,25 @@ def split_chat_history_markdown(text, include_tool=False):
|
||||||
return messages
|
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):
|
def get_pip_install(args):
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
get_best_invocation_for_this_python(),
|
||||||
"-m",
|
"-m",
|
||||||
"pip",
|
"pip",
|
||||||
"install",
|
"install",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue