-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_app.py
59 lines (43 loc) · 1.89 KB
/
start_app.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
# Made by https://github.com/pythoninoffice
#adjusted by SimolZimol
import importlib.util
import platform
import subprocess
import sys
import pathlib
import time
python = sys.executable
required_lib = ['torch', 'onnxruntime', 'transformers', 'scipy', 'ftfy', 'discord.py']
standard_onnx = 'onnx'
repositories = pathlib.Path().absolute() / 'repositories'
git_repos = ['https://github.com/huggingface/diffusers']
requirements = pathlib.Path().absolute() /'requirements.txt'
def pip_install(lib):
subprocess.run(f'echo Installing {lib}...', shell=True)
subprocess.run(f'echo "{python}" -m pip install {lib}', shell=True)
subprocess.run(f'"{python}" -m pip install {lib}', shell=True, capture_output=True)
subprocess.run(f'"{python}" -m pip install {lib}', shell=True, capture_output=True)
def pip_install_requirements():
subprocess.run(f'echo installing requirements', shell=True)
subprocess.run(f'"{python}" -m pip install -r requirements.txt', shell=True, capture_output=True)
def is_installed(lib):
library = importlib.util.find_spec(lib)
return (library is not None)
def git_clone(repo_url, repo_name):
repo_dir = repositories/repo_name
if not repo_dir.exists():
repo_dir.mkdir(parents=True, exist_ok=True)
subprocess.run(f'echo cloning {repo_dir}', shell=True)
subprocess.run(f'git clone {repo_url} "{repo_dir}"', shell=True)
else:
subprocess.run(f'echo {repo_name} already exists!', shell=True)
#git_clone('https://github.com/huggingface/diffusers','diffusers')
#subprocess.run(rf'echo "{python}" -m pip install -e .\repositories\diffusers', shell=True)
#subprocess.run(rf'"{python}" -m pip install -e .\repositories\diffusers', shell=True, capture_output=True)
#for lib in required_lib:
# if not is_installed(lib):
# pip_install(lib)
pip_install_requirements()
subprocess.run('echo Done installing', shell=True)
import bot
bot()