From eb3fc065c92bb6a9182240b3e4cf722f26c72b7e Mon Sep 17 00:00:00 2001 From: Nose Date: Thu, 22 Jan 2026 00:33:57 -0800 Subject: [PATCH] f --- scripts/bootstrap.py | 53 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 7e24b51..f7b720a 100644 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -535,25 +535,23 @@ def main() -> int: if p is None: return False return (p / "CLI.py").exists() and (p / "scripts").exists() - # If running from a pipe/standalone, don't auto-probe the current directory - # as a repo. This prevents "auto-choosing" existing folders in Web Installer mode. - is_in_repo = False + # Detect if we are already inside a valid Medios-Macina repo + is_in_repo = _is_valid_mm_repo(repo_root) + if not is_in_repo and _is_valid_mm_repo(Path.cwd()): + repo_root = Path.cwd() + script_dir = repo_root / "scripts" + is_in_repo = True + + # If running from a pipe/standalone (Web Installer Mode), we force is_in_repo = False + # so that Option 1 will always provide the path prompt rather than auto-detecting. if script_path is None: - pass - else: - # Check if we are already inside a valid Medios-Macina repo. - # We do this to provide a sensible default if we need to prompt the user. - # But we don't set is_in_repo = True yet, so that _ensure_repo_available - # will still prompt for confirmation in interactive mode. - if not _is_valid_mm_repo(repo_root): - if _is_valid_mm_repo(Path.cwd()): - repo_root = Path.cwd() - script_dir = repo_root / "scripts" + is_in_repo = False if not args.quiet and args.debug: print(f"Bootstrap script location: {script_dir}") print(f"Project root: {repo_root}") print(f"Current working directory: {Path.cwd()}") + print(f"Is in repo: {is_in_repo}") # Helpers for interactive menu and uninstall detection def _venv_python_path(p: Path) -> Path | None: @@ -1057,9 +1055,32 @@ def main() -> int: args.install_editable = True args.no_playwright = False elif sel == "extras_hydrus": - if not _ensure_repo_available(): - return 1 - hydrus_script = repo_root / "scripts" / "hydrusnetwork.py" + # Choice 2 is for installing HydrusNetwork standalone/independently. + # We preferentially use the local script if already in a repo. + hydrus_script = None + if is_in_repo and repo_root: + hydrus_script = repo_root / "scripts" / "hydrusnetwork.py" + + if not hydrus_script or not hydrus_script.exists(): + # If truly not in a repo (Web Installer), we don't want to install + # Medios-Macina permanently. We'll use a temporary clone to get the installer. + print("\n[Standalone Hydrus Installation]") + print("Downloading the Hydrus installation helper...") + try: + import tempfile + # Create a temporary directory that persists for this run + temp_repo = Path(tempfile.mkdtemp(prefix="mm_hydrus_")) + if _clone_repo(REPO_URL, temp_repo, depth=1): + hydrus_script = temp_repo / "scripts" / "hydrusnetwork.py" + # We temporarily set repo_root so the script finds its dependencies if needed + repo_root = temp_repo + else: + print("Error: Could not download the installation helper.") + return 1 + except Exception as e: + print(f"Error setting up temporary installer: {e}") + return 1 + if hydrus_script.exists(): try: # Clear out project-venv related env vars to prevent auto-reexec