Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'--no-default-browser-check'
]

USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'

# Timeouts
LOGIN_TIMEOUT_MINUTES = 10
Expand Down
24 changes: 20 additions & 4 deletions scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
Ensures all scripts run with the correct virtual environment
"""

import os
import sys

# Force UTF-8 for stdout/stderr so emoji prints don't crash on Windows,
# where the default console encoding is cp1252.
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
sys.stderr.reconfigure(encoding='utf-8', errors='replace')

import os
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -34,8 +41,11 @@ def ensure_venv():
print("🔧 First-time setup: Creating virtual environment...")
print(" This may take a minute...")

# Run setup with system Python
result = subprocess.run([sys.executable, str(setup_script)])
# Run setup with system Python; propagate UTF-8 so the setup
# script's emoji prints survive on Windows.
setup_env = os.environ.copy()
setup_env.setdefault('PYTHONIOENCODING', 'utf-8')
result = subprocess.run([sys.executable, str(setup_script)], env=setup_env)
if result.returncode != 0:
print("❌ Failed to set up environment")
sys.exit(1)
Expand Down Expand Up @@ -86,9 +96,15 @@ def main():
# Build command
cmd = [str(venv_python), str(script_path)] + script_args

# Propagate UTF-8 to the child process so emoji prints in the called
# script (auth_manager / notebook_manager / ask_question) don't crash
# on Windows.
child_env = os.environ.copy()
child_env.setdefault('PYTHONIOENCODING', 'utf-8')

# Run the script
try:
result = subprocess.run(cmd)
result = subprocess.run(cmd, env=child_env)
sys.exit(result.returncode)
except KeyboardInterrupt:
print("\n⚠️ Interrupted by user")
Expand Down
6 changes: 4 additions & 2 deletions scripts/setup_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def ensure_venv(self) -> bool:
if self.requirements_file.exists():
print("📦 Installing dependencies...")
try:
# Upgrade pip first
# Upgrade pip via `python -m pip` (instead of `pip.exe install
# --upgrade pip`) so Windows can replace pip without hitting a
# FileLock on the running pip.exe.
subprocess.run(
[str(self.venv_pip), "install", "--upgrade", "pip"],
[str(self.venv_python), "-m", "pip", "install", "--upgrade", "pip"],
check=True,
capture_output=True,
text=True
Expand Down