使用pip-tools安装mower-ng的依赖
This commit is contained in:
parent
ffc2ff6808
commit
92ef815d0d
4 changed files with 18 additions and 20 deletions
|
@ -7,7 +7,6 @@ from pathlib import Path
|
|||
from shutil import rmtree
|
||||
from subprocess import Popen
|
||||
|
||||
import chardet
|
||||
import requests
|
||||
|
||||
from launcher import config
|
||||
|
@ -29,27 +28,27 @@ command_list = {
|
|||
"fetch": lambda: f"..\\git\\bin\\git fetch origin {config.conf.branch} --progress",
|
||||
"switch": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=100 switch -f {config.conf.branch} --progress",
|
||||
"reset": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=200 reset --hard origin/{config.conf.branch}",
|
||||
"pip_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} -r requirements.txt --no-warn-script-location",
|
||||
"pip_tools_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} pip-tools --no-warn-script-location",
|
||||
"pip_sync": lambda: f"..\\python\\Scripts\\pip-sync -i {mirror_list[config.conf.mirror]} requirements.txt",
|
||||
"webview": "start ..\\python\\pythonw webview_ui.py",
|
||||
"manager": "start ..\\python\\pythonw manager.py",
|
||||
}
|
||||
|
||||
|
||||
def detect_encoding(stream):
|
||||
# 读取一部分数据来检测编码
|
||||
raw_data = stream.read(4096)
|
||||
result = chardet.detect(raw_data)
|
||||
stream.seek(0) # 将流指针重置到开头
|
||||
return result['encoding']
|
||||
|
||||
|
||||
def read_stream(stream, log_func):
|
||||
detected_encoding = detect_encoding(stream)
|
||||
text_io = io.TextIOWrapper(stream, encoding=detected_encoding, errors='replace')
|
||||
try:
|
||||
def process_lines(text_io):
|
||||
for line in iter(text_io.readline, ''):
|
||||
text = line.rstrip('\n')
|
||||
custom_event(text.strip() + "\n")
|
||||
custom_event(f"{text.strip()}\n")
|
||||
|
||||
detected_encoding = 'utf-8'
|
||||
text_io = io.TextIOWrapper(stream, encoding=detected_encoding, errors='replace')
|
||||
try:
|
||||
process_lines(text_io)
|
||||
except UnicodeDecodeError:
|
||||
stream.seek(0) # 重新将流指针重置到开头
|
||||
text_io = io.TextIOWrapper(stream, encoding='gbk', errors='replace')
|
||||
process_lines(text_io)
|
||||
finally:
|
||||
text_io.close()
|
||||
|
||||
|
@ -136,7 +135,7 @@ class Api:
|
|||
universal_newlines=False
|
||||
) as p:
|
||||
stdout_thread = threading.Thread(target=read_stream, args=(p.stdout, logger.info))
|
||||
stderr_thread = threading.Thread(target=read_stream, args=(p.stderr, logger.info))
|
||||
stderr_thread = threading.Thread(target=read_stream, args=(p.stderr, logger.error))
|
||||
|
||||
stdout_thread.start()
|
||||
stderr_thread.start()
|
||||
|
@ -145,7 +144,9 @@ class Api:
|
|||
stderr_thread.join()
|
||||
if p.returncode == 0:
|
||||
return "success"
|
||||
else:
|
||||
logger.error(f"{command} 运行失败")
|
||||
return "failed"
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
custom_event(str(e))
|
||||
return "failed"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
pywebview==5.1
|
||||
requests==2.32.3
|
||||
py7zr==0.22.0
|
||||
chardet==5.2.0
|
||||
pydantic==2.10.3
|
||||
|
|
|
@ -16,8 +16,6 @@ certifi==2024.12.14
|
|||
# via requests
|
||||
cffi==1.17.1
|
||||
# via clr-loader
|
||||
chardet==5.2.0
|
||||
# via -r requirements.in
|
||||
charset-normalizer==3.4.0
|
||||
# via requests
|
||||
clr-loader==0.2.7.post0
|
||||
|
|
|
@ -13,7 +13,7 @@ const steps = computed(() => [
|
|||
},
|
||||
{
|
||||
title: '安装依赖',
|
||||
command: ['pip_install'],
|
||||
command: ['pip_tools_install', 'pip_sync'],
|
||||
cwd: 'mower-ng'
|
||||
}
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue