mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
feat: improve version update handling for Windows and Docker
This commit is contained in:
parent
5fe85f7233
commit
62c89f60bf
2 changed files with 34 additions and 25 deletions
|
@ -302,7 +302,7 @@ def touch_file(fname):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=False):
|
||||||
if module:
|
if module:
|
||||||
try:
|
try:
|
||||||
__import__(module)
|
__import__(module)
|
||||||
|
@ -315,6 +315,11 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||||
if prompt:
|
if prompt:
|
||||||
io.tool_error(prompt)
|
io.tool_error(prompt)
|
||||||
|
|
||||||
|
if self_update and platform.system() == "Windows":
|
||||||
|
io.tool_output("Run this command to update:")
|
||||||
|
io.tool_output(printable_shell_command(cmd))
|
||||||
|
return
|
||||||
|
|
||||||
if not io.confirm_ask("Run pip install?", default="y", subject=printable_shell_command(cmd)):
|
if not io.confirm_ask("Run pip install?", default="y", subject=printable_shell_command(cmd)):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,44 @@ def install_from_main_branch(io):
|
||||||
None,
|
None,
|
||||||
"Install the development version of aider from the main branch?",
|
"Install the development version of aider from the main branch?",
|
||||||
["--upgrade", "git+https://github.com/paul-gauthier/aider.git"],
|
["--upgrade", "git+https://github.com/paul-gauthier/aider.git"],
|
||||||
|
self_update=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_upgrade(io):
|
def install_upgrade(io, latest_version=None):
|
||||||
"""
|
"""
|
||||||
Install the latest version of aider from PyPI.
|
Install the latest version of aider from PyPI.
|
||||||
"""
|
"""
|
||||||
return utils.check_pip_install_extra(
|
|
||||||
|
if latest_version:
|
||||||
|
new_ver_text = f"Newer aider version v{latest_version} is available."
|
||||||
|
else:
|
||||||
|
new_ver_text = f"Install latest version of aider from PyPI?"
|
||||||
|
|
||||||
|
docker_image = os.environ.get("AIDER_DOCKER_IMAGE")
|
||||||
|
if docker_image:
|
||||||
|
text = f"""
|
||||||
|
{new_ver_text} To upgrade, run:
|
||||||
|
|
||||||
|
docker pull {docker_image}
|
||||||
|
"""
|
||||||
|
io.tool_error(text)
|
||||||
|
return True
|
||||||
|
|
||||||
|
success = utils.check_pip_install_extra(
|
||||||
io,
|
io,
|
||||||
None,
|
None,
|
||||||
"Install the latest version of aider from PyPI?",
|
new_ver_text,
|
||||||
["--upgrade", "aider-chat"],
|
["--upgrade", "aider-chat"],
|
||||||
|
self_update=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
io.tool_output("Re-run aider to use new version.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def check_version(io, just_check=False, verbose=False):
|
def check_version(io, just_check=False, verbose=False):
|
||||||
if not just_check and VERSION_CHECK_FNAME.exists():
|
if not just_check and VERSION_CHECK_FNAME.exists():
|
||||||
|
@ -85,25 +109,5 @@ def check_version(io, just_check=False, verbose=False):
|
||||||
if not is_update_available:
|
if not is_update_available:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
docker_image = os.environ.get("AIDER_DOCKER_IMAGE")
|
install_upgrade(io, latest_version)
|
||||||
if docker_image:
|
|
||||||
text = f"""
|
|
||||||
Newer aider version v{latest_version} is available. To upgrade, run:
|
|
||||||
|
|
||||||
docker pull {docker_image}
|
|
||||||
"""
|
|
||||||
io.tool_error(text)
|
|
||||||
return True
|
|
||||||
|
|
||||||
success = utils.check_pip_install_extra(
|
|
||||||
io,
|
|
||||||
None,
|
|
||||||
f"Newer aider version v{latest_version} is available.",
|
|
||||||
["--upgrade", "aider-chat"],
|
|
||||||
)
|
|
||||||
|
|
||||||
if success:
|
|
||||||
io.tool_output("Re-run aider to use new version.")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue