Skip to content

Commit dc4e199

Browse files
committed
have --update all also upgrade any pip requirements.txt
1 parent 3a9b255 commit dc4e199

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

llms/main.py

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,19 +3941,20 @@ async def install_extension(name):
39413941

39423942
# Check for requirements.txt
39433943
requirements_path = os.path.join(target_path, "requirements.txt")
3944+
3945+
# Check if uv is installed
3946+
has_uv = False
3947+
try:
3948+
subprocess.run(
3949+
["uv", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True
3950+
)
3951+
has_uv = True
3952+
except (subprocess.CalledProcessError, FileNotFoundError):
3953+
pass
3954+
39443955
if os.path.exists(requirements_path):
39453956
print(f"Installing dependencies from {requirements_path}...")
39463957

3947-
# Check if uv is installed
3948-
has_uv = False
3949-
try:
3950-
subprocess.run(
3951-
["uv", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True
3952-
)
3953-
has_uv = True
3954-
except (subprocess.CalledProcessError, FileNotFoundError):
3955-
pass
3956-
39573958
if has_uv:
39583959
subprocess.run(
39593960
["uv", "pip", "install", "-p", sys.executable, "-r", "requirements.txt"],
@@ -4041,6 +4042,36 @@ async def update_extensions(extension_name):
40414042
print(f"Updated extension {extension}")
40424043
_log(result.stdout.decode("utf-8"))
40434044

4045+
requirements_path = os.path.join(extension_path, "requirements.txt")
4046+
4047+
has_uv = False
4048+
try:
4049+
subprocess.run(
4050+
["uv", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True
4051+
)
4052+
has_uv = True
4053+
except (subprocess.CalledProcessError, FileNotFoundError):
4054+
pass
4055+
4056+
if os.path.exists(requirements_path):
4057+
print(f"Upgrading dependencies from {requirements_path}...")
4058+
try:
4059+
if has_uv:
4060+
subprocess.run(
4061+
["uv", "pip", "install", "-U", "-p", sys.executable, "-r", "requirements.txt"],
4062+
cwd=extension_path,
4063+
check=True,
4064+
)
4065+
else:
4066+
subprocess.run(
4067+
[sys.executable, "-m", "pip", "install", "-U", "-r", "requirements.txt"],
4068+
cwd=extension_path,
4069+
check=True,
4070+
)
4071+
print("Dependencies upgraded successfully.")
4072+
except subprocess.CalledProcessError as e:
4073+
print(f"Failed to upgrade dependencies: {e}")
4074+
40444075
asyncio.run(update_extensions(cli_args.update))
40454076
return ExitCode.SUCCESS
40464077

0 commit comments

Comments
 (0)