This commit is contained in:
2026-01-21 23:27:48 -08:00
parent dc6a66cf67
commit 3ff751acc5

View File

@@ -69,14 +69,21 @@ def _ensure_interactive_stdin() -> None:
if not sys.stdin.isatty():
try:
if platform.system().lower() == "windows":
sys.stdin = open("CONIN$", "r")
# Ensure the handle is actually opened for reading correctly
new_stdin = open("CONIN$", "r")
sys.stdin = new_stdin
else:
sys.stdin = open("/dev/tty", "r")
except Exception:
pass
# Flush existing buffers to ensure clean state
if hasattr(sys.stdin, 'flush'):
sys.stdin.flush()
except Exception as e:
if "--debug" in sys.argv:
print(f"DEBUG: Failed to re-open stdin: {e}")
def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[Path] = None) -> None:
def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[Path] = None, env: Optional[dict[str, str]] = None) -> None:
if debug:
print(f"\n> {' '.join(cmd)}")
@@ -85,12 +92,13 @@ def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
cwd=str(cwd) if cwd else None
cwd=str(cwd) if cwd else None,
env=env
)
else:
if not debug:
print(f"> {' '.join(cmd)}")
subprocess.check_call(cmd, cwd=str(cwd) if cwd else None)
subprocess.check_call(cmd, cwd=str(cwd) if cwd else None, env=env)
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
@@ -787,14 +795,20 @@ def main() -> int:
return False
try:
if script_path is not None:
if is_in_repo and script_path is not None:
default_install = repo_root
else:
default_install = Path.cwd() / "Medios-Macina"
print("\n[WEB INSTALLER MODE]")
print(f"Current working directory: {Path.cwd()}")
print("Where would you like to install Medios-Macina?")
install_dir_raw = input(f"Installation directory [{default_install}]: ").strip()
# Use sys.stdin.readline() to be more robust than input() in some terminal environments
sys.stdout.write(f"Installation directory [{default_install}]: ")
sys.stdout.flush()
install_dir_raw = sys.stdin.readline().strip()
if not install_dir_raw:
install_path = default_install
else:
@@ -992,7 +1006,14 @@ def main() -> int:
hydrus_script = repo_root / "scripts" / "hydrusnetwork.py"
if hydrus_script.exists():
try:
subprocess.check_call([sys.executable, str(hydrus_script)])
# Clear out project-venv related env vars to prevent auto-reexec
env = os.environ.copy()
env.pop("VIRTUAL_ENV", None)
env.pop("PYTHONHOME", None)
env.pop("PYTHONPATH", None)
# We use sys.executable (the one running bootstrap.py) to run hydrusnetwork.py
# This ensures it uses the same environment that started the bootstrap.
subprocess.check_call([sys.executable, str(hydrus_script), "--no-project-venv"], env=env)
except subprocess.CalledProcessError:
print("\nHydrusNetwork setup exited with an error.")
except Exception as e: