forked from JarodMica/Vivy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_multithread.py
37 lines (30 loc) · 1.16 KB
/
build_multithread.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
import subprocess
import glob
import os
import shutil
import concurrent.futures
assistants = ['one_up', 'roleplay', 'interview', 'assistantp', 'assistant', 'chat']
assistants_path = "assistants"
current_dir = os.path.dirname(os.path.abspath(__file__))
print(current_dir)
distpath = os.path.join(current_dir, assistants_path)
def compile_assistant(assistant):
cmd = ["pyinstaller",
"--onefile",
"--distpath=" f"{distpath}",
f"{assistants_path}/{assistant}.py"]
subprocess.run(cmd, shell=False)
if __name__ == '__main__':
# Add freeze_support() for Windows platforms
if os.name == 'nt':
from multiprocessing import freeze_support
freeze_support()
# Process all assistants in parallel
with concurrent.futures.ProcessPoolExecutor() as executor:
results = [executor.submit(compile_assistant, assistant) for assistant in assistants]
# Delete all .spec files in the current directory
for spec_file in glob.glob("*.spec"):
os.remove(spec_file)
# Removes build folder (if you don't want this, you can comment this out)
shutil.rmtree("build")
input("Press Enter to continue...")