Skip to content

Commit d18571f

Browse files
committed
Added install_system_packages function to sys_deps.py
1 parent 87388a9 commit d18571f

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Core/sys_deps.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,3 +934,46 @@ def check_system_packages(packages: list[str]) -> bool:
934934
return True
935935
except Exception:
936936
return False
937+
938+
939+
def install_system_packages(packages: list[str], gui=None) -> bool:
940+
"""
941+
Install system packages using the appropriate package manager.
942+
Returns True if successful, False otherwise.
943+
"""
944+
try:
945+
manager = SysDependencyManager(gui)
946+
system = platform.system().lower()
947+
948+
if system == "linux":
949+
# For Linux, use the install_packages_linux method
950+
process = manager.install_packages_linux(packages)
951+
if process:
952+
# Wait for completion (simplified - in practice should be async)
953+
process.waitForFinished(300000) # 5 minutes timeout
954+
return process.exitCode() == 0
955+
elif system == "windows":
956+
# For Windows, convert package names to winget format
957+
# This is a simplified mapping - in practice would need proper mapping
958+
winget_packages = []
959+
for pkg in packages:
960+
# Basic mapping - would need expansion for real use
961+
if pkg == "build-essential":
962+
winget_packages.append({"id": "Microsoft.VisualStudio.2022.BuildTools"})
963+
elif pkg == "python3-dev":
964+
winget_packages.append({"id": "Python.Python.3"})
965+
else:
966+
# Generic fallback
967+
winget_packages.append({"id": pkg})
968+
969+
process = manager.install_packages_windows(winget_packages)
970+
if process:
971+
process.waitForFinished(300000) # 5 minutes timeout
972+
return process.exitCode() == 0
973+
else:
974+
# Unsupported platform
975+
return False
976+
977+
return False
978+
except Exception:
979+
return False

0 commit comments

Comments
 (0)