mirror of
https://github.com/dw-0/kiauh.git
synced 2026-05-04 16:28:22 +05:00
fix(switch_repo): honor use_python_binary when recreating venv (#793)
* fix(switch_repo): honor use_python_binary when recreating venv * fix(switch_repo): validate name at function entry
This commit is contained in:
@@ -31,6 +31,7 @@ from components.moonraker.services.moonraker_setup_service import (
|
|||||||
from core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from core.logger import Logger
|
from core.logger import Logger
|
||||||
from core.services.backup_service import BackupService
|
from core.services.backup_service import BackupService
|
||||||
|
from core.settings.kiauh_settings import KiauhSettings
|
||||||
from utils.git_utils import GitException, git_clone_wrapper
|
from utils.git_utils import GitException, git_clone_wrapper
|
||||||
from utils.instance_utils import get_instances
|
from utils.instance_utils import get_instances
|
||||||
from utils.sys_utils import (
|
from utils.sys_utils import (
|
||||||
@@ -47,6 +48,11 @@ class RepoSwitchFailedException(Exception):
|
|||||||
def run_switch_repo_routine(
|
def run_switch_repo_routine(
|
||||||
name: Literal["klipper", "moonraker"], repo_url: str, branch: str
|
name: Literal["klipper", "moonraker"], repo_url: str, branch: str
|
||||||
) -> None:
|
) -> None:
|
||||||
|
if name not in ("klipper", "moonraker"):
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid name: {name!r}. Must be 'klipper' or 'moonraker'."
|
||||||
|
)
|
||||||
|
|
||||||
repo_dir: Path = KLIPPER_DIR if name == "klipper" else MOONRAKER_DIR
|
repo_dir: Path = KLIPPER_DIR if name == "klipper" else MOONRAKER_DIR
|
||||||
env_dir: Path = KLIPPER_ENV_DIR if name == "klipper" else MOONRAKER_ENV_DIR
|
env_dir: Path = KLIPPER_ENV_DIR if name == "klipper" else MOONRAKER_ENV_DIR
|
||||||
req_file = KLIPPER_REQ_FILE if name == "klipper" else MOONRAKER_REQ_FILE
|
req_file = KLIPPER_REQ_FILE if name == "klipper" else MOONRAKER_REQ_FILE
|
||||||
@@ -89,7 +95,16 @@ def run_switch_repo_routine(
|
|||||||
|
|
||||||
# step 6: recreate python virtualenv
|
# step 6: recreate python virtualenv
|
||||||
Logger.print_status(f"Recreating {_type.__name__} virtualenv ...")
|
Logger.print_status(f"Recreating {_type.__name__} virtualenv ...")
|
||||||
if not create_python_venv(env_dir, force=True):
|
|
||||||
|
settings = KiauhSettings()
|
||||||
|
if name == "klipper":
|
||||||
|
use_python_binary = settings.klipper.use_python_binary
|
||||||
|
elif name == "moonraker":
|
||||||
|
use_python_binary = settings.moonraker.use_python_binary
|
||||||
|
|
||||||
|
if not create_python_venv(
|
||||||
|
env_dir, force=True, use_python_binary=use_python_binary
|
||||||
|
):
|
||||||
raise GitException(f"Failed to recreate virtualenv for {_type.__name__}")
|
raise GitException(f"Failed to recreate virtualenv for {_type.__name__}")
|
||||||
else:
|
else:
|
||||||
install_python_requirements(env_dir, req_file)
|
install_python_requirements(env_dir, req_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user