LunaTranslator/cpp/scripts/fetchwebview2.py

56 lines
2.0 KiB
Python
Raw Normal View History

2024-06-18 17:44:02 +08:00
mswebview2_version = "1.0.2535.41"
2024-06-05 02:27:47 +08:00
import os, subprocess
target = os.path.normpath(os.path.join(os.path.dirname(__file__), r"..\libs\webview2"))
os.makedirs(target, exist_ok=True)
nuget_exe = os.path.join(target, "nuget.exe")
print(nuget_exe)
if os.path.exists(nuget_exe) == False:
os.system(
2024-11-04 23:10:41 +08:00
rf'curl -SLo "{nuget_exe}" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
2024-06-05 02:27:47 +08:00
)
mswebview2_dir = os.path.join(target, f"Microsoft.Web.WebView2.{mswebview2_version}")
if os.path.exists(mswebview2_dir) == False:
os.mkdir(mswebview2_dir)
print(
rf""""{nuget_exe}" install Microsoft.Web.Webview2 -Verbosity quiet -Version "{mswebview2_version}" -OutputDirectory {target}"""
)
subprocess.run(
rf'"{nuget_exe}" install Microsoft.Web.Webview2 -Verbosity quiet -Version "{mswebview2_version}" -OutputDirectory {target}'
)
2024-11-04 23:10:41 +08:00
onnx = os.path.normpath(
os.path.join(
os.path.dirname(__file__), "../libs/onnxruntime-static/windows-x64/lib/onnx.lib"
)
)
opencv = os.path.normpath(
os.path.join(
os.path.dirname(__file__),
2024-11-05 16:14:51 +08:00
r"..\libs\opencv-static\windows-x64\x64\vc16\staticlib\opencv_core470.lib",
2024-11-04 23:10:41 +08:00
)
)
onnx_1 = os.path.normpath(
2024-11-05 15:46:45 +08:00
os.path.join(os.path.dirname(__file__), "../libs/onnxruntime-static/onnxruntime-static.7z")
2024-11-04 23:10:41 +08:00
)
opencv_1 = os.path.normpath(
2024-11-05 15:46:45 +08:00
os.path.join(os.path.dirname(__file__), r"..\libs\opencv-static\opencv-static.7z")
2024-11-04 23:10:41 +08:00
)
if os.path.exists(onnx) == False:
2024-11-05 15:46:45 +08:00
os.makedirs(os.path.dirname(onnx_1), exist_ok=True)
2024-11-04 23:10:41 +08:00
os.system(
2024-11-05 15:46:45 +08:00
rf'curl -SLo "{onnx_1}" https://github.com/RapidAI/OnnxruntimeBuilder/releases/download/1.14.1/onnxruntime-1.14.1-vs2019-static-mt.7z'
2024-11-04 23:10:41 +08:00
)
2024-11-05 15:46:45 +08:00
os.system(rf'7z x -y "{onnx_1}" -o{os.path.dirname(onnx_1)}')
2024-11-04 23:10:41 +08:00
if os.path.exists(opencv) == False:
2024-11-05 15:46:45 +08:00
os.makedirs(os.path.dirname(opencv_1), exist_ok=True)
2024-11-04 23:10:41 +08:00
os.system(
2024-11-05 16:14:51 +08:00
rf'curl -SLo "{opencv_1}" https://github.com/RapidAI/OpenCVBuilder/releases/download/4.7.0/opencv-4.7.0-windows-vs2019-mt.7z'
2024-11-04 23:10:41 +08:00
)
os.system(rf'7z x -y "{opencv_1}" -o{os.path.dirname(opencv_1)}')