-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprepare_environment.py
More file actions
38 lines (32 loc) · 1.28 KB
/
prepare_environment.py
File metadata and controls
38 lines (32 loc) · 1.28 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
import os
import shutil
import subprocess
import sys
def ensure_pip():
subprocess.check_call([sys.executable, "-m", "ensurepip"])
def update_pip():
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
def install_packages():
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
def prepare_spec_files():
shutil.copyfile("ebme.spec.TEMPLATE", "ebme.spec")
def compile_resources():
# pyside6-rcc is not on path by default, so to be safe we'll use the full path
full_path = os.path.join(os.path.dirname(sys.executable), "pyside6-rcc")
try:
subprocess.check_call([full_path, "resources.qrc", "-o", "resources_rc.py"])
except FileNotFoundError: # not in a venv. particularly an issue for github actions
full_path = os.path.join(os.path.dirname(sys.executable), "Scripts", "pyside6-rcc")
subprocess.check_call([full_path, "resources.qrc", "-o", "resources_rc.py"])
if __name__ == "__main__":
print("Ensuring pip...")
ensure_pip()
print("Updaing pip...")
update_pip()
print("Installing packages...")
install_packages()
print("Preparing .spec files...")
prepare_spec_files()
print("Compiling resources...")
compile_resources()
print("Done!")