ff
This commit is contained in:
@@ -1092,6 +1092,7 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
"--upgrade",
|
||||
"-r",
|
||||
str(req)
|
||||
],
|
||||
|
||||
@@ -73,7 +73,8 @@ def find_requirements(root: Path) -> Optional[Path]:
|
||||
def install_requirements(
|
||||
venv_py: Path,
|
||||
req_path: Path,
|
||||
reinstall: bool = False
|
||||
reinstall: bool = False,
|
||||
upgrade: bool = False
|
||||
) -> bool:
|
||||
try:
|
||||
# Suppression flag for Windows
|
||||
@@ -81,7 +82,7 @@ def install_requirements(
|
||||
if os.name == "nt":
|
||||
kwargs["creationflags"] = 0x08000000
|
||||
|
||||
print(f"Installing {req_path} into venv ({venv_py})...")
|
||||
print(f"Installing/Updating {req_path} into venv ({venv_py})...")
|
||||
subprocess.run(
|
||||
[str(venv_py),
|
||||
"-m",
|
||||
@@ -93,6 +94,8 @@ def install_requirements(
|
||||
**kwargs
|
||||
)
|
||||
install_cmd = [str(venv_py), "-m", "pip", "install", "-r", str(req_path)]
|
||||
if upgrade:
|
||||
install_cmd = [str(venv_py), "-m", "pip", "install", "--upgrade", "-r", str(req_path)]
|
||||
if reinstall:
|
||||
install_cmd = [
|
||||
str(venv_py),
|
||||
@@ -913,6 +916,11 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
action="store_true",
|
||||
help="Run 'git pull' before starting the client",
|
||||
)
|
||||
p.add_argument(
|
||||
"--update-deps",
|
||||
action="store_true",
|
||||
help="Update python dependencies to latest compatible versions on startup",
|
||||
)
|
||||
p.add_argument(
|
||||
"--gui",
|
||||
action="store_true",
|
||||
@@ -1105,12 +1113,29 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
cwd = Path(args.cwd).resolve() if args.cwd else repo_root
|
||||
|
||||
# Optionally install dependencies
|
||||
if args.install_deps or args.reinstall:
|
||||
# Automatically update dependencies if we pulled new code or if forced via env/flag
|
||||
should_update = args.update_deps or os.environ.get("MM_UPDATE_DEPS") == "1"
|
||||
|
||||
# Check config.conf for auto_update_deps
|
||||
config_path = repo_root / "config.conf"
|
||||
if not should_update and config_path.exists():
|
||||
try:
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
if "auto_update_deps=true" in content.lower().replace(" ", ""):
|
||||
should_update = True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not should_update and args.pull and not (args.install_service or args.uninstall_service):
|
||||
should_update = True
|
||||
|
||||
if args.install_deps or args.reinstall or should_update:
|
||||
req = find_requirements(repo_root)
|
||||
if not req:
|
||||
print("No requirements.txt found; skipping install")
|
||||
else:
|
||||
ok = install_requirements(venv_py, req, reinstall=args.reinstall)
|
||||
ok = install_requirements(venv_py, req, reinstall=args.reinstall, upgrade=should_update)
|
||||
if not ok:
|
||||
print("Dependency installation failed; aborting")
|
||||
return 4
|
||||
@@ -1124,7 +1149,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
)
|
||||
|
||||
# If not installing but user asked to verify, do verification only
|
||||
if args.verify and not (args.install_deps or args.reinstall):
|
||||
if args.verify and not (args.install_deps or args.reinstall or should_update):
|
||||
req = find_requirements(repo_root)
|
||||
if req:
|
||||
pkgs = parse_requirements_file(req)
|
||||
|
||||
Reference in New Issue
Block a user