forked from mohamed-chs/chatgpt-history-export-to-md
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
50 lines (40 loc) · 1.46 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
import os
import sys
import venv
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
VENV_DIR = os.path.join(BASE_DIR, ".venv")
def create_virtual_environment():
# Create virtual environment
env_builder = venv.EnvBuilder(with_pip=True)
env_builder.create(VENV_DIR)
def pip_install_requirements():
pip_exe = (
os.path.join(VENV_DIR, "bin", "pip")
if sys.platform != "win32"
else os.path.join(VENV_DIR, "Scripts", "pip.exe")
)
# Install requirements
os.system(f"{pip_exe} install -r requirements.txt")
if __name__ == "__main__":
if sys.version_info < (3, 10):
print(
"Python 3.10 or higher is required to run this program.\n"
"Please download the latest version of Python at :\n"
"https://www.python.org/downloads/ 🔗, and try again.\n"
"Exiting..."
)
sys.exit(1)
print("Creating virtual environment...\n")
create_virtual_environment()
print("Installing requirements... (This may take a minute..)\n")
pip_install_requirements()
# Post-setup instructions
print("\nSetup completed successfully!")
print(
"\nTo activate the virtual environment, use the following command based on your platform:"
)
if sys.platform == "win32":
print("\nFor Command Prompt:\n.venv\\Scripts\\activate.bat")
print("\nFor PowerShell:\n.venv\\Scripts\\Activate.ps1")
else:
print("\nsource .venv/bin/activate")