Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
66 lines (51 loc) · 2.21 KB
/
Copy pathsetup.py
File metadata and controls
66 lines (51 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import subprocess
import sys
from pathlib import Path
def install_requirements():
print("Installing Python dependencies...")
command = [sys.executable, "-m", "pip", "install", "--user", "-r", "requirements.txt"]
subprocess.check_call(command)
print("Dependencies installed.")
def create_env_file():
env_path = Path(".env")
existing_lines = []
if env_path.exists():
existing_lines = env_path.read_text(encoding="utf-8").splitlines()
print(".env already exists. Adding any missing values.")
else:
print("Creating a new .env file.")
def ensure_env_value(key, value):
for line in existing_lines:
if line.startswith(f"{key}="):
return
existing_lines.append(f"{key}={value}")
print("\nPlease enter your OpenRouter API key.")
api_key = input("OPENROUTER_API_KEY: ").strip()
print("\nPlease enter your name (optional).")
user_name = input("USER_NAME [User]: ").strip() or "User"
print("\nEnter GUI window size (optional).")
width = input("GUI_window_width [800]: ").strip() or "800"
height = input("GUI_window_height [600]: ").strip() or "600"
print("\nEnter GUI window resizable options (optional).")
is_width_resizable = input("IS_WIDTH_RESIZABLE [True]: ").strip() or "True"
is_height_resizable = input("IS_HEIGHT_RESIZABLE [True]: ").strip() or "True"
ensure_env_value("OPENROUTER_API_KEY", api_key)
ensure_env_value("USER_NAME", user_name)
ensure_env_value("GUI_window_width", width)
ensure_env_value("GUI_window_height", height)
ensure_env_value("IS_WIDTH_RESIZABLE", is_width_resizable)
ensure_env_value("IS_HEIGHT_RESIZABLE", is_height_resizable)
env_content = "\n".join(existing_lines).strip() + "\n"
env_path.write_text(env_content, encoding="utf-8")
print(f"Updated {env_path} with your settings.")
def ask_to_continue():
answer = input("\nDo you want to continue to main.py? [y/N]: ").strip().lower()
if answer in {"y", "yes"}:
print("Starting main.py...")
import main.py
else:
print("Setup complete. You can run main.py later.")
if __name__ == "__main__":
install_requirements()
create_env_file()
ask_to_continue()