-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
36 lines (29 loc) · 1.23 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
import os
import platform
import subprocess
import sys
def create_virtualenv():
"""Create a virtual environment using appropriate method based on OS."""
venv_dir = "venv"
if not os.path.exists(venv_dir):
if platform.system() == "Windows":
subprocess.check_call([sys.executable, "-m", "venv", venv_dir])
else:
subprocess.check_call([sys.executable, "-m", "venv", venv_dir])
def install_requirements():
"""Install requirements from requirements.txt."""
subprocess.check_call([os.path.join("venv", "bin" if not platform.system() == "Windows" else "Scripts", "pip"),
"install", "-r", "requirements.txt"])
def main():
print("Creating virtual environment...")
create_virtualenv()
print("Installing requirements...")
install_requirements()
print("Building the executable...")
subprocess.check_call([os.path.join("venv", "bin" if not platform.system() == "Windows" else "Scripts", "pyinstaller"),
"--onefile",
"--add-data", "resources:resources",
"--add-data", "appresources:appresources",
"app.py"])
if __name__ == "__main__":
main()