forked from IrisRainbowNeko/genshin_auto_fish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IrisRainbowNeko#101 from wasabiegg/master
add proxy option to requirements installation, change capture screen from pyautogui to winapi
- Loading branch information
Showing
4 changed files
with
155 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
windows: | ||
monitor_width: 1920 | ||
monitor_height: 1080 | ||
game: | ||
window_name: "原神" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,74 @@ | ||
import pip | ||
# import pip | ||
import subprocess | ||
import sys | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description='install requirements') | ||
parser.add_argument('--cuda', default=None, type=str) | ||
args = parser.parse_args() | ||
|
||
pkgs=f''' | ||
cython | ||
scikit-image | ||
loguru | ||
matplotlib | ||
tabulate | ||
tqdm | ||
pywin32 | ||
PyAutoGUI | ||
opencv_python | ||
keyboard | ||
Pillow | ||
pymouse | ||
numpy==1.19.5 | ||
torch==1.7.0+{"cpu" if args.cuda is None else "cu" + args.cuda} -f https://download.pytorch.org/whl/torch_stable.html | ||
torchvision==0.8.1+{"cpu" if args.cuda is None else "cu" + args.cuda} --no-deps -f https://download.pytorch.org/whl/torch_stable.html | ||
thop --no-deps | ||
git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI | ||
''' | ||
|
||
for line in pkgs.split('\n'): | ||
if len(line)>0: | ||
pip.main(['install', *line.split()]) | ||
# 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.7.0+{"cpu" if args.cuda is None else "cu" + args.cuda} -f https://download.pytorch.org/whl/torch_stable.html | ||
torchvision==0.8.1+{"cpu" if args.cuda is None else "cu" + args.cuda} --no-deps -f https://download.pytorch.org/whl/torch_stable.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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters