From f004380dafbfaa0c42e35990c037be6a2bec5e4f Mon Sep 17 00:00:00 2001 From: test123456654321 <16307130148@fudan.edu.cn> Date: Sat, 2 Nov 2024 19:55:32 +0800 Subject: [PATCH] actions (#1128) --- .github/workflows/build.yml | 65 ++++++--- .github/workflows/release.yml | 96 +++++++------ src/LunaTranslator/LunaTranslator_main.py | 8 +- src/LunaTranslator/gobject.py | 2 +- .../gui/setting_display_text.py | 2 +- src/LunaTranslator/gui/usefulwidget.py | 11 +- src/build.py | 128 +++++++++++------- src/collectall.py | 107 +++++++++++++++ src/{retrieval.py => collectpyruntime.py} | 122 ++++------------- src/files/defaultconfig/static_data.json | 14 -- src/plugins/CMakeLists.txt | 2 +- src/plugins/exec/PyStand.cpp | 2 +- 12 files changed, 321 insertions(+), 238 deletions(-) create mode 100644 src/collectall.py rename src/{retrieval.py => collectpyruntime.py} (60%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 42eb9658..68b5fae5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,46 @@ on: paths: [ '.github/workflows/build.yml','src/**'] jobs: - build: + pyrt: runs-on: windows-latest + strategy: + matrix: + architecture: [x86, x64] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.7.9' + architecture: ${{ matrix.architecture }} + + - run: python src/build.py pyrt ${{ matrix.architecture }} 3.7.9 + - uses: actions/upload-artifact@v4 + with: + name: pyrt_${{ matrix.architecture }} + path: src/pyrt + build_cpp: + runs-on: windows-latest + strategy: + matrix: + architecture: [x86, x64] + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 + with: + sdk-version: 22621 + + - run: python src/build.py cpp ${{ matrix.architecture }} + - uses: actions/upload-artifact@v4 + with: + name: cpp_${{ matrix.architecture }} + path: src/plugins/builds + + + release: + runs-on: windows-latest + needs: [pyrt,build_cpp] strategy: matrix: include: @@ -17,27 +55,12 @@ jobs: - architecture: x64 fname: LunaTranslator steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup Windows 10 SDK - uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: - sdk-version: 22621 - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: '3.7.9' - architecture: ${{ matrix.architecture }} - - - name: Install Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Run build script - run: | - python src/build.py ${{ matrix.architecture }} 3.7.9 + path: build + - run: python src/build.py merge ${{ matrix.architecture }} - uses: actions/upload-artifact@v4 with: name: ${{ matrix.fname }} - path: src/build/${{ matrix.fname }}.zip + path: src/build/${{matrix.fname}}.zip \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45d8aff5..c7151e64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,55 @@ on: workflow_dispatch: jobs: - build: + loadversion: runs-on: windows-latest + outputs: + version: ${{ steps.loadversion.outputs.version }} + steps: + - uses: actions/checkout@v4 + - id: loadversion + run: python src/build.py loadversion | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append + + pyrt: + runs-on: windows-latest + strategy: + matrix: + architecture: [x86, x64] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.7.9' + architecture: ${{ matrix.architecture }} + + - run: python src/build.py pyrt ${{ matrix.architecture }} 3.7.9 + - uses: actions/upload-artifact@v4 + with: + name: pyrt_${{ matrix.architecture }} + path: src/pyrt + build_cpp: + runs-on: windows-latest + strategy: + matrix: + architecture: [x86, x64] + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 + with: + sdk-version: 22621 + + - run: python src/build.py cpp ${{ matrix.architecture }} + - uses: actions/upload-artifact@v4 + with: + name: cpp_${{ matrix.architecture }} + path: src/plugins/builds + + + release: + runs-on: windows-latest + needs: [pyrt,build_cpp,loadversion] strategy: matrix: include: @@ -13,47 +60,16 @@ jobs: fname: LunaTranslator_x86 - architecture: x64 fname: LunaTranslator - permissions: - id-token: write - attestations: write - contents: write steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup Windows 10 SDK - uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: - sdk-version: 22621 - - name: Install Python - uses: actions/setup-python@v5 + path: build + - run: python src/build.py merge ${{ matrix.architecture }} + - uses: softprops/action-gh-release@v2 with: - python-version: '3.7.9' - architecture: ${{ matrix.architecture }} - - name: Install Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Run build script - run: | - python src/build.py ${{ matrix.architecture }} 3.7.9 - # - name: Generate attestation for artifact - # uses: actions/attest-build-provenance@v1 - # with: - # subject-path: build/${{ matrix.fname }}.zip - - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.fname }} - path: src/build/${{ matrix.fname }}.zip - - - name: loadversion - id: loadversion - run: python src/build.py loadversion | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append - - name: Release LunaTranslator - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.loadversion.outputs.version }} + tag_name: ${{ needs.loadversion.outputs.version }} files: | - src/build/${{ matrix.fname }}.zip - src/build/${{ matrix.fname }}.exe + src/build/${{matrix.fname}}.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/src/LunaTranslator/LunaTranslator_main.py b/src/LunaTranslator/LunaTranslator_main.py index af18c496..f9b5f890 100644 --- a/src/LunaTranslator/LunaTranslator_main.py +++ b/src/LunaTranslator/LunaTranslator_main.py @@ -22,8 +22,8 @@ def prepareqtenv(): import windows # win7 no vcredist2015 - windows.addenvpath("./LunaTranslator/runtime/") - windows.loadlibrary("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll") + windows.addenvpath("./files/runtime/") + windows.loadlibrary("./files/runtime/PyQt5/Qt5/bin/Qt5Core.dll") from qtsymbols import QApplication, isqt5, Qt, QFont, QLocale @@ -31,10 +31,10 @@ def prepareqtenv(): if isqt5: # 中文字符下不能自动加载 - QApplication.addLibraryPath("./LunaTranslator/runtime/PyQt5/Qt5/plugins") + QApplication.addLibraryPath("./files/runtime/PyQt5/Qt5/plugins") QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling) QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) - if os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"): + if os.path.exists("./files/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"): # maybe use qwebengine QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts) diff --git a/src/LunaTranslator/gobject.py b/src/LunaTranslator/gobject.py index 8074a3db..c5c6b5d0 100644 --- a/src/LunaTranslator/gobject.py +++ b/src/LunaTranslator/gobject.py @@ -45,7 +45,7 @@ def gettempdir(filename): def testuseqwebengine(): - return os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll") + return os.path.exists("./files/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll") from LunaTranslator import MAINUI diff --git a/src/LunaTranslator/gui/setting_display_text.py b/src/LunaTranslator/gui/setting_display_text.py index 5b26b2f8..a48b1d73 100644 --- a/src/LunaTranslator/gui/setting_display_text.py +++ b/src/LunaTranslator/gui/setting_display_text.py @@ -182,7 +182,7 @@ def doinstallqweb(self, dd, base): target = gobject.gettempdir("QWebEngine/") zipf.extractall(target) bit = ["x86", "x64"][platform.architecture()[0] == "64bit"] - copytree(f"{target}/{bit}/PyQt5", "LunaTranslator/runtime/PyQt5") + copytree(f"{target}/{bit}/PyQt5", "files/runtime/PyQt5") getQMessageBox(self, "成功", "安装成功") diff --git a/src/LunaTranslator/gui/usefulwidget.py b/src/LunaTranslator/gui/usefulwidget.py index 03d78827..75440548 100644 --- a/src/LunaTranslator/gui/usefulwidget.py +++ b/src/LunaTranslator/gui/usefulwidget.py @@ -2,7 +2,7 @@ from qtsymbols import * import os, platform, functools, uuid, json, math, csv, io, pickle from traceback import print_exc import windows, qtawesome, winsharedutils, gobject -from webviewpy import webview_native_handle_kind_t, Webview, declare_library_path +from webviewpy import webview_native_handle_kind_t, Webview from winsharedutils import HTMLBrowser from myutils.config import _TR, globalconfig, _TRL from myutils.wrapper import Singleton_close, tryprint @@ -1225,15 +1225,6 @@ class WebivewWidget(abstractwebview): def __init__(self, parent=None, debug=True, usedarklight=True) -> None: super().__init__(parent) - declare_library_path( - os.path.abspath( - os.path.join( - "files/plugins/", - ("DLL32", "DLL64")[platform.architecture()[0] == "64bit"], - "webview", - ) - ) - ) self.webview = None self.webview = Webview(debug=debug, window=int(self.winId())) zoomfunc = winsharedutils.add_ZoomFactorChanged_CALLBACK( diff --git a/src/build.py b/src/build.py index 51f0ae4e..57ee3421 100644 --- a/src/build.py +++ b/src/build.py @@ -5,6 +5,10 @@ import urllib.request from urllib.parse import urljoin rootDir = os.path.dirname(__file__) +if not rootDir: + rootDir = os.path.abspath(".") +else: + rootDir = os.path.abspath(rootDir) if sys.argv[1] == "loadversion": os.chdir(rootDir) with open("plugins/CMakeLists.txt", "r", encoding="utf8") as ff: @@ -15,6 +19,10 @@ if sys.argv[1] == "loadversion": print("version=" + versionstring) exit() +print(sys.version) +print(__file__) +print(rootDir) + mylinks = { "LunaHook": "https://github.com/HIllya51/LunaHook/releases/latest/download/Release_English.zip", "ocr_models": { @@ -188,7 +196,7 @@ def get_url_as_json(url): time.sleep(3) -def buildLunaHook(): +def downLunaHook(): os.chdir(rootDir + "\\temp") LunaHook_latest = mylinks["LunaHook"] @@ -212,23 +220,25 @@ def buildLunaHook(): ) -def buildPlugins(): +def buildPlugins(arch): os.chdir(rootDir + "\\plugins\\scripts") subprocess.run("python fetchwebview2.py") - subprocess.run( - f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86 -DCMAKE_SYSTEM_VERSION=10.0.26621.0' - ) - subprocess.run( - f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14" - ) - subprocess.run(f"python copytarget.py 1") - subprocess.run( - f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64 -DCMAKE_SYSTEM_VERSION=10.0.26621.0' - ) - subprocess.run( - f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14" - ) - subprocess.run(f"python copytarget.py 0") + if arch == "x86": + subprocess.run( + f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86 -DCMAKE_SYSTEM_VERSION=10.0.26621.0' + ) + subprocess.run( + f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14" + ) + # subprocess.run(f"python copytarget.py 1") + else: + subprocess.run( + f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64 -DCMAKE_SYSTEM_VERSION=10.0.26621.0' + ) + subprocess.run( + f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14" + ) + # subprocess.run(f"python copytarget.py 0") def downloadsomething(): @@ -254,39 +264,59 @@ def downloadbass(): if __name__ == "__main__": - arch = sys.argv[1] - version = sys.argv[2] os.chdir(rootDir) - os.system("git submodule update --init --recursive") os.makedirs("temp", exist_ok=True) + arch = sys.argv[2] + if sys.argv[1] == "cpp": + installVCLTL() + buildPlugins(arch) + elif sys.argv[1] == "pyrt": + version = sys.argv[3] + if arch == "x86": + py37Path = ( + f"C:\\hostedtoolcache\\windows\\Python\\{version}\\x86\\python.exe" + ) + else: + py37Path = ( + f"C:\\hostedtoolcache\\windows\\Python\\{version}\\x64\\python.exe" + ) + os.chdir(rootDir) + subprocess.run(f"{py37Path} -m pip install --upgrade pip") + subprocess.run(f"{py37Path} -m pip install -r requirements.txt") + # 3.8之后会莫名其妙引用这个b东西,然后这个b东西会把一堆没用的东西导入进来 + shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\test")) + shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\unittest")) + # 放弃,3.8需要安装KB2533623才能运行,3.7用不着。 + subprocess.run(f"{py37Path} collectpyruntime.py") + elif sys.argv[1] == "merge": + createPluginDirs() + downloadsomething() + downloadBrotli() + downloadLocaleEmulator() + downloadNtlea() + downloadCurl() + downloadOCRModel() + downloadcommon() + downloadbass() + downLunaHook() + os.chdir(rootDir) + shutil.copytree( + f"{rootDir}/../build/cpp_x86", + f"{rootDir}/plugins/builds", + dirs_exist_ok=True, + ) + shutil.copytree( + f"{rootDir}/../build/cpp_x64", + f"{rootDir}/plugins/builds", + dirs_exist_ok=True, + ) + os.chdir(rootDir + "\\plugins\\scripts") + subprocess.run(f"python copytarget.py 1") + subprocess.run(f"python copytarget.py 0") - createPluginDirs() - downloadsomething() - downloadBrotli() - downloadLocaleEmulator() - downloadNtlea() - downloadCurl() - downloadOCRModel() - downloadcommon() - downloadbass() - buildLunaHook() - - installVCLTL() - buildPlugins() - - os.chdir(rootDir) - - if arch == "x86": - py37Path = f"C:\\hostedtoolcache\\windows\\Python\\{version}\\x86\\python.exe" - else: - py37Path = f"C:\\hostedtoolcache\\windows\\Python\\{version}\\x64\\python.exe" - - os.chdir(rootDir) - - subprocess.run(f"{py37Path} -m pip install --upgrade pip") - subprocess.run(f"{py37Path} -m pip install -r requirements.txt") - # 3.8之后会莫名其妙引用这个b东西,然后这个b东西会把一堆没用的东西导入进来 - shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\test")) - shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\unittest")) - # 放弃,3.8需要安装KB2533623才能运行,3.7用不着。 - subprocess.run(f"{py37Path} retrieval.py") + if arch == "x86": + os.chdir(rootDir) + os.system("python collectall.py 32") + else: + os.chdir(rootDir) + os.system("python collectall.py 64") diff --git a/src/collectall.py b/src/collectall.py new file mode 100644 index 00000000..05b668aa --- /dev/null +++ b/src/collectall.py @@ -0,0 +1,107 @@ +import shutil, os +import platform +import sys +from importanalysis import importanalysis + +x86 = platform.architecture()[0] == "32bit" +if sys.argv[1] == "32": + targetdir = r"build\LunaTranslator_x86" + launch = r"plugins\builds\_x86" + baddll = "DLL64" + pyrt = "../build/pyrt_x86/runtime" +else: + baddll = "DLL32" + launch = r"plugins\builds\_x64" + targetdir = r"build\LunaTranslator" + pyrt = "../build/pyrt_x64/runtime" + + +def copycheck(src, tgt): + print(src, tgt, os.path.exists(src)) + if not os.path.exists(src): + return + if src.lower().endswith("_ssl.pyd"): + return + if not os.path.exists(tgt): + os.makedirs(tgt, exist_ok=True) + if os.path.isdir(src): + tgt = os.path.join(tgt, os.path.basename(src)) + if os.path.exists(tgt): + shutil.rmtree(tgt) + shutil.copytree(src, tgt) + return + shutil.copy(src, tgt) + + +copycheck(os.path.join(launch, "LunaTranslator.exe"), targetdir) +copycheck(os.path.join(launch, "LunaTranslator_admin.exe"), targetdir) +copycheck(os.path.join(launch, "LunaTranslator_debug.exe"), targetdir) +copycheck("./LunaTranslator", targetdir) +copycheck(r".\files", targetdir) +copycheck(pyrt, targetdir + "/files") +try: + shutil.rmtree(rf"{targetdir}\files\plugins\{baddll}") +except: + pass +shutil.copy(r"..\LICENSE", targetdir) + +collect = [] +for _dir, _, fs in os.walk(targetdir): + for f in fs: + collect.append(os.path.join(_dir, f)) +for f in collect: + if f.endswith(".pyc") or f.endswith("Thumbs.db"): + os.remove(f) + elif f.endswith(".exe") or f.endswith(".pyd") or f.endswith(".dll"): + if f.endswith("Magpie.Core.exe"): + continue + print(f) + imports = importanalysis(f) + print(f, imports) + if len(imports) == 0: + continue + with open(f, "rb") as ff: + bs = bytearray(ff.read()) + for _dll, offset in imports: + if _dll.lower().startswith("api-ms-win-core"): + # 其实对于api-ms-win-core-winrt-XXX实际上是到ComBase.dll之类的,不过此项目中不包含这些 + _target = "kernel32.dll" + elif _dll.lower().startswith("api-ms-win-crt"): + _target = "ucrtbase.dll" + else: + continue + _dll = _dll.encode() + _target = _target.encode() + # print(len(bs)) + bs[offset : offset + len(_dll)] = _target + b"\0" * ( + len(_dll) - len(_target) + ) + # print(len(bs)) + with open(f, "wb") as ff: + ff.write(bs) + +target = os.path.basename(targetdir) +os.chdir(os.path.dirname(targetdir)) +if os.path.exists(rf"{target}.zip"): + os.remove(rf"{target}.zip") +if os.path.exists(rf"{target}.7z"): + os.remove(rf"{target}.7z") +os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=Deflate -mx9 {target}.zip {target}') +if 0: + os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA2 -mx9 {target}.7z {target}') + with open(r"C:\Program Files\7-Zip\7z.sfx", "rb") as ff: + sfx = ff.read() + + config = """ + ;!@Install@!UTF-8! + + + ;!@InstallEnd@! + """ + with open(rf"{target}.7z", "rb") as ff: + data = ff.read() + + with open(rf"{target}.exe", "wb") as ff: + ff.write(sfx) + ff.write(config.encode("utf8")) + ff.write(data) diff --git a/src/retrieval.py b/src/collectpyruntime.py similarity index 60% rename from src/retrieval.py rename to src/collectpyruntime.py index ecdb5fee..7a4b51b1 100644 --- a/src/retrieval.py +++ b/src/collectpyruntime.py @@ -1,34 +1,20 @@ +import os import modulefinder, shutil, os, sys import builtins, platform import sys -from importanalysis import importanalysis pyversion = platform.python_version() pyversion2 = "".join(pyversion.split(".")[:2]) x86 = platform.architecture()[0] == "32bit" +runtime = r"pyrt\runtime" if x86: + webviewpath = r"webviewpy\platform\win32\x86" downlevel = r"C:\Windows\SysWOW64\downlevel" - - runtime = r"build\LunaTranslator_x86\LunaTranslator\runtime" - targetdir = r"build\LunaTranslator_x86" - launch = r"plugins\builds\_x86" - baddll = "DLL64" - gooddll = "DLL32" - - webviewappendix = r"Lib\site-packages\webviewpy\platform\win32\x86\webview.dll" else: - baddll = "DLL32" - gooddll = "DLL64" - launch = r"plugins\builds\_x64" - runtime = r"build\LunaTranslator\LunaTranslator\runtime" - targetdir = r"build\LunaTranslator" + webviewpath = r"webviewpy\platform\win32\x64" downlevel = r"C:\Windows\system32\downlevel" - - webviewappendix = r"Lib\site-packages\webviewpy\platform\win32\x64\webview.dll" - py37Path = os.path.dirname(sys.executable) print(py37Path) -py37Pathwebview = os.path.join(py37Path, webviewappendix) def get_dependencies(filename): @@ -73,20 +59,6 @@ def copycheck(src, tgt): shutil.copy(src, tgt) -if os.path.exists(targetdir): - shutil.rmtree(targetdir) -copycheck(os.path.join(launch, "LunaTranslator.exe"), targetdir) -copycheck(os.path.join(launch, "LunaTranslator_admin.exe"), targetdir) -copycheck(os.path.join(launch, "LunaTranslator_debug.exe"), targetdir) -copycheck("./LunaTranslator", targetdir) -copycheck(r".\files", targetdir) -try: - shutil.rmtree(rf"{targetdir}\files\plugins\{baddll}") -except: - pass -shutil.copy(r"..\LICENSE", targetdir) -shutil.copy(py37Pathwebview, rf"{targetdir}\files\plugins\{gooddll}") - all_dependencies = set() for _d, _, _fs in os.walk("./LunaTranslator"): for f in _fs: @@ -128,7 +100,6 @@ for dependency in all_dependencies: tgtreal = os.path.join(runtime, os.path.dirname(end)) copycheck(dependency, tgtreal) - with open(os.path.join(runtime, f"python{pyversion2}._pth"), "w") as ff: ff.write("..\n.") @@ -141,6 +112,28 @@ copycheck(os.path.join(py37Path, "DLLs/libffi-7.dll"), runtime) copycheck(rf"{downlevel}\ucrtbase.dll", runtime) + +copycheck( + os.path.join(py37Path, "Lib/site-packages", webviewpath, "webview.dll"), + os.path.join(runtime, webviewpath), +) + +copycheck( + os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/vcruntime140.dll"), + os.path.join(runtime), +) +copycheck( + os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/vcruntime140_1.dll"), + os.path.join(runtime), +) +copycheck( + os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/msvcp140.dll"), + os.path.join(runtime), +) +copycheck( + os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/msvcp140_1.dll"), + os.path.join(runtime), +) copycheck( os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/vcruntime140.dll"), os.path.join(runtime), @@ -157,8 +150,6 @@ copycheck( os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/msvcp140_1.dll"), os.path.join(runtime), ) - - for _ in os.listdir(os.path.join(py37Path, "Lib/site-packages/PyQt5")): if _.startswith("sip"): copycheck( @@ -204,64 +195,3 @@ copycheck( ), os.path.join(runtime, "PyQt5/Qt5/plugins/styles"), ) - -collect = [] -for _dir, _, fs in os.walk(targetdir): - for f in fs: - collect.append(os.path.join(_dir, f)) -for f in collect: - if f.endswith(".pyc") or f.endswith("Thumbs.db"): - os.remove(f) - elif f.endswith(".exe") or f.endswith(".pyd") or f.endswith(".dll"): - if f.endswith("Magpie.Core.exe"): - continue - print(f) - imports = importanalysis(f) - print(f, imports) - if len(imports) == 0: - continue - with open(f, "rb") as ff: - bs = bytearray(ff.read()) - for _dll, offset in imports: - if _dll.lower().startswith("api-ms-win-core"): - # 其实对于api-ms-win-core-winrt-XXX实际上是到ComBase.dll之类的,不过此项目中不包含这些 - _target = "kernel32.dll" - elif _dll.lower().startswith("api-ms-win-crt"): - _target = "ucrtbase.dll" - else: - continue - _dll = _dll.encode() - _target = _target.encode() - # print(len(bs)) - bs[offset : offset + len(_dll)] = _target + b"\0" * ( - len(_dll) - len(_target) - ) - # print(len(bs)) - with open(f, "wb") as ff: - ff.write(bs) - -target = os.path.basename(targetdir) -os.chdir(os.path.dirname(targetdir)) -if os.path.exists(rf"{target}.zip"): - os.remove(rf"{target}.zip") -if os.path.exists(rf"{target}.7z"): - os.remove(rf"{target}.7z") -os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=Deflate -mx9 {target}.zip {target}') -if 0: - os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA2 -mx9 {target}.7z {target}') - with open(r"C:\Program Files\7-Zip\7z.sfx", "rb") as ff: - sfx = ff.read() - - config = """ - ;!@Install@!UTF-8! - - - ;!@InstallEnd@! - """ - with open(rf"{target}.7z", "rb") as ff: - data = ff.read() - - with open(rf"{target}.exe", "wb") as ff: - ff.write(sfx) - ff.write(config.encode("utf8")) - ff.write(data) diff --git a/src/files/defaultconfig/static_data.json b/src/files/defaultconfig/static_data.json index 5618c84a..7c223a8b 100644 --- a/src/files/defaultconfig/static_data.json +++ b/src/files/defaultconfig/static_data.json @@ -1265,20 +1265,6 @@ "link": "{main_server}/Resource/Magpie9_Win7" } ] - }, - { - "name": "QWebEngine", - "type": "group", - "links": [ - { - "name": "x86", - "link": "{main_server}/Resource/QWebEngine_x86.zip" - }, - { - "name": "x64", - "link": "{main_server}/Resource/QWebEngine_x64.zip" - } - ] } ] } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 76da6922..a621ad91 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 53) -set(VERSION_PATCH 8) +set(VERSION_PATCH 9) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h) diff --git a/src/plugins/exec/PyStand.cpp b/src/plugins/exec/PyStand.cpp index d694d35d..c9ffa19b 100644 --- a/src/plugins/exec/PyStand.cpp +++ b/src/plugins/exec/PyStand.cpp @@ -339,7 +339,7 @@ int main() return 0; } auto __handle = AutoHandle(CreateMutexA(&allAccess, FALSE, "LUNA_UPDATER_BLOCK")); - PyStand ps(L"LunaTranslator\\runtime"); + PyStand ps(L"files\\runtime"); if (ps.DetectScript() != 0) { return 3;