This commit is contained in:
2026-01-22 03:47:01 -08:00
parent 672599743f
commit fac0fdb463

View File

@@ -56,6 +56,7 @@ import argparse
import os
import platform
import re
import urllib.request
from pathlib import Path
import shutil
import subprocess
@@ -118,6 +119,7 @@ def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
HYDRUS_INSTALLER_SCRIPT_URL = "https://raw.githubusercontent.com/hydrusnetwork/hydrus/master/scripts/hydrusnetwork.py"
class ProgressBar:
@@ -900,6 +902,16 @@ def main() -> int:
print(f"Error: Failed to clone repository: {e}", file=sys.stderr)
return False
def _download_hydrus_installer(dest: Path) -> bool:
"""Download the hydrusnetwork.py helper script into the provided path."""
try:
with urllib.request.urlopen(HYDRUS_INSTALLER_SCRIPT_URL) as response:
dest.write_bytes(response.read())
return True
except Exception as e:
print(f"Error: Failed to download Hydrus installer script: {e}", file=sys.stderr)
return False
def _ensure_repo_available() -> bool:
"""Prompt for a clone location when running outside the repository."""
nonlocal repo_root, script_dir, is_in_repo
@@ -1134,28 +1146,30 @@ def main() -> int:
# Choice 2 is for installing HydrusNetwork standalone/independently.
# We preferentially use the local script if already in a repo.
hydrus_script = None
temp_installer_path: Path | None = 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("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
fd, path = tempfile.mkstemp(prefix="mm_hydrus_", suffix=".py")
os.close(fd)
helper_path = Path(path)
if _download_hydrus_installer(helper_path):
hydrus_script = helper_path
temp_installer_path = helper_path
else:
print("Error: Could not download the installation helper.")
helper_path.unlink(missing_ok=True)
return 1
except Exception as e:
print(f"Error setting up temporary installer: {e}")
return 1
if hydrus_script.exists():
if hydrus_script and hydrus_script.exists():
try:
# Clear out project-venv related env vars to prevent auto-reexec
env = os.environ.copy()
@@ -1182,6 +1196,9 @@ def main() -> int:
print("\nHydrusNetwork setup exited with an error.")
except Exception as e:
print(f"\nFailed to run HydrusNetwork setup: {e}")
finally:
if temp_installer_path:
temp_installer_path.unlink(missing_ok=True)
else:
print(f"\nError: {hydrus_script} not found.")
return 0