-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
159 lines (128 loc) · 4.45 KB
/
Copy pathinstall.py
File metadata and controls
159 lines (128 loc) · 4.45 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python3
"""
Prima Engine — Install / Update / Run script.
Usage:
python install.py install Install from local source
python install.py update Pull latest from git + reinstall
python install.py run Launch the editor
python install.py server Start a game server
python install.py --help Show this help
"""
import os
import sys
import subprocess
import platform
import shutil
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
REQUIREMENTS = [
"numpy",
"PyOpenGL",
"PyQt5",
"scikit-build-core>=0.10.0",
"nanobind>=2.0.0",
]
def check_python():
if sys.version_info < (3, 10):
print("[!] Python 3.10+ required")
sys.exit(1)
print(f"[✓] Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
def run(cmd, cwd=None, capture=False):
print(f" $ {' '.join(cmd)}")
kwargs = {"cwd": cwd or PROJECT_DIR}
if capture:
return subprocess.run(cmd, check=True, capture_output=True, text=True, **kwargs)
subprocess.run(cmd, check=True, **kwargs)
def cmd_install():
check_python()
print("\n[1/4] Installing Python dependencies...")
pip = [sys.executable, "-m", "pip", "install"]
run(pip + REQUIREMENTS)
print("\n[2/4] Building C++ physics module...")
run([sys.executable, "-m", "pip", "install", "-e", ".", "--no-build-isolation"])
print("\n[3/4] Verifying installation...")
try:
from prima.engine._physics import PhysicsWorld
print("[✓] C++ physics module loaded")
except ImportError as e:
print(f"[!] Physics module not available: {e}")
try:
from prima.engine import Engine
from prima.server import GameServer
from prima.client import GameWindow
print("[✓] All Python modules import correctly")
except ImportError as e:
print(f"[!] Import error: {e}")
sys.exit(1)
print("\n[4/4] Creating desktop entry...")
_create_desktop_entry()
print("\n[✓] Prima Engine installed successfully")
print(" Run: python install.py run")
print(" Or: python main.py")
def cmd_update():
print("\n[1/2] Pulling latest source from git...")
run(["git", "pull"])
print("\n[2/2] Rebuilding...")
cmd_install()
def cmd_run():
print("Launching Prima Editor...")
os.chdir(PROJECT_DIR)
run([sys.executable, "main.py"])
def cmd_server():
print("Launching Prima Server...")
os.chdir(PROJECT_DIR)
run([sys.executable, "-m", "prima.server.cli"] + sys.argv[2:])
def _create_desktop_entry():
if platform.system() != "Linux":
return
desktop_dir = os.path.expanduser("~/.local/share/applications")
os.makedirs(desktop_dir, exist_ok=True)
icon_path = os.path.join(PROJECT_DIR, "prima", "assets", "icon.png")
entry = f"""[Desktop Entry]
Type=Application
Name=Prima Engine
Comment=3D Game Engine
Exec={sys.executable} {os.path.join(PROJECT_DIR, 'main.py')}
Icon={icon_path if os.path.exists(icon_path) else 'applications-graphics'}
Terminal=false
Categories=Development;Game;
"""
path = os.path.join(desktop_dir, "prima-engine.desktop")
with open(path, "w") as f:
f.write(entry)
os.chmod(path, 0o755)
print(f"[✓] Desktop entry: {path}")
def _init_git():
if os.path.isdir(os.path.join(PROJECT_DIR, ".git")):
return
print("\n[!] No git repo found. Initialize one for updates? [Y/n] ", end="")
answer = input().strip().lower()
if answer in ("", "y", "yes"):
run(["git", "init"])
run(["git", "checkout", "-b", "main"])
run(["git", "add", "-A"])
run(["git", "commit", "-m", "Initial commit"])
print("\n[✓] Git repo initialized")
print(" To push to GitHub:")
print(" 1. Create a repo at https://github.com/new")
print(" 2. Run:")
print(f" git remote add origin https://github.com/YOUR_USER/PrimaEngine.git")
print(f" git push -u origin main")
def main():
if len(sys.argv) < 2 or sys.argv[1] in ("--help", "-h"):
print(__doc__.strip())
return
command = sys.argv[1]
if command == "install":
cmd_install()
elif command == "update":
cmd_update()
elif command == "run":
cmd_run()
elif command == "server":
cmd_server()
else:
print(f"Unknown command: {command}")
print(__doc__.strip())
sys.exit(1)
if __name__ == "__main__":
main()