forked from IrisRainbowNeko/genshin_auto_fish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
requirements.py
74 lines (62 loc) · 2.13 KB
/
requirements.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# import pip
import subprocess
import sys
import argparse
# use python type hints to make code more readable
from typing import List, Optional
def pip_install(proxy: Optional[str], args: List[str]) -> None:
if proxy is None:
# pip.main(["install", f"--proxy={proxy}", *args])
subprocess.run(
[sys.executable, "-m", "pip", "install", *args],
# capture_output=False,
check=True,
)
else:
subprocess.run(
[sys.executable, "-m", "pip", "install", f"--proxy={proxy}", *args],
# capture_output=False,
check=True,
)
def main():
parser = argparse.ArgumentParser(description="install requirements")
parser.add_argument("--cuda", default=None, type=str)
parser.add_argument(
"--proxy",
default=None,
type=str,
help="specify http proxy, [http://127.0.0.1:1080]",
)
args = parser.parse_args()
pkgs = f"""
cython
scikit-image
loguru
matplotlib
tabulate
tqdm
pywin32
PyAutoGUI
PyYAML>=5.3.1
opencv_python
keyboard
Pillow
pymouse
numpy==1.19.5
torch==1.8.2+{"cpu" if args.cuda is None else "cu" + args.cuda} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
torchvision==0.9.2+{"cpu" if args.cuda is None else "cu" + args.cuda} --no-deps -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
thop --no-deps
git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
"""
for line in pkgs.split("\n"):
# handle multiple space in an empty line
line = line.strip()
if len(line) > 0:
# use pip's internal APIs in this way is deprecated. This will fail in a future version of pip.
# The most reliable approach, and the one that is fully supported, is to run pip in a subprocess.
# ref: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
# pip.main(['install', *line.split()])
pip_install(args.proxy, line.split())
print("\nsuccessfully installed requirements!")
if __name__ == "__main__":
main()