forked from 101dotxyz/GPTeam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
70 lines (53 loc) · 1.94 KB
/
setup.py
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
#!/usr/bin/env python3
import os
import platform
import subprocess
def is_poetry_installed():
try:
subprocess.run(["poetry", "--version"], capture_output=True, check=True)
return True
except FileNotFoundError:
return False
except subprocess.CalledProcessError:
return False
def install_poetry():
install_cmd = "curl -sSL https://install.python-poetry.org | python3 -"
os.system(install_cmd)
if os_type == "Windows":
poetry_bin_path = os.path.expanduser("~\\AppData\\Roaming\\Python\\Scripts")
else:
poetry_bin_path = os.path.expanduser("~/.local/bin")
if poetry_bin_path not in os.environ["PATH"]:
if os_type == "Windows":
os.environ["PATH"] = f"{poetry_bin_path};{os.environ['PATH']}"
else:
os.environ["PATH"] = f"{poetry_bin_path}:{os.environ['PATH']}"
if __name__ == "__main__":
os_type = platform.system()
if os.environ.get("CI") == "true":
# Skip user prompts when running in CI environment
prompt = False
else:
prompt = True
if is_poetry_installed():
print("Poetry is already installed.")
else:
if prompt:
answer = input(
"⚠️ Poetry not found. Would you like to install it now? (y/n): "
)
if answer.lower() != "y":
exit(1)
print("Installing Poetry...")
install_poetry()
# copy .env.example to .env
if not os.path.exists(".env"):
print("Creating .env file...")
subprocess.run(["cp", ".env.example", ".env"], check=True)
print("Installing dependencies...")
subprocess.run(["poetry", "install"], check=True)
print("Seed the database...")
subprocess.run(["poetry", "run", "db-reset"], check=True)
print(
"\nSetup complete!\n\n-> You are ready to run the world. Please set your OPENAI_API_KEY in .env and run `poetry run world` to get started."
)