From d8346dabddeff3973e873abeadaef42015b020d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Fri, 15 Nov 2024 01:33:17 +0800 Subject: [PATCH] build --- .github/scripts/build_lunatranslator.py | 46 ++++++++++++++----------- .github/workflows/buildluna.yml | 2 ++ py/LunaTranslator/LunaTranslator.py | 4 +-- py/files/themes/.keepdir | 0 4 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 py/files/themes/.keepdir diff --git a/.github/scripts/build_lunatranslator.py b/.github/scripts/build_lunatranslator.py index 116a5a5b..490ddd14 100644 --- a/.github/scripts/build_lunatranslator.py +++ b/.github/scripts/build_lunatranslator.py @@ -9,8 +9,8 @@ if not rootDir: rootDir = os.path.abspath(".") else: rootDir = os.path.abspath(rootDir) -rootthisfiledir=rootDir -rootDir=os.path.abspath(os.path.join(rootDir,'../../py')) +rootthisfiledir = rootDir +rootDir = os.path.abspath(os.path.join(rootDir, "../../py")) if sys.argv[1] == "loadversion": os.chdir(rootDir) with open("../cpp/version.cmake", "r", encoding="utf8") as ff: @@ -193,6 +193,7 @@ def get_url_as_json(url): except: time.sleep(3) + def buildPlugins(arch): os.chdir(rootDir + "\\..\\cpp\\scripts") subprocess.run("python fetchwebview2.py") @@ -215,10 +216,7 @@ def buildPlugins(arch): def downloadsomething(): - os.chdir(rootDir + "\\temp") - subprocess.run(f"curl -LO {mylinks['themes.zip']}") - subprocess.run(f"7z x themes.zip -oALL") - move_directory_contents("ALL/themes", rootDir + "\\files\\themes") + shutil.rmtree(rootDir + "\\files\\LunaTranslator_qss\\.git") def downloadbass(): @@ -260,7 +258,9 @@ if __name__ == "__main__": 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} {os.path.join(rootthisfiledir,'collectpyruntime.py')}") + subprocess.run( + f"{py37Path} {os.path.join(rootthisfiledir,'collectpyruntime.py')}" + ) elif sys.argv[1] == "merge": createPluginDirs() downloadsomething() @@ -294,20 +294,24 @@ if __name__ == "__main__": ) os.chdir(rootDir + "/../cpp/scripts") - os.makedirs('../../py/files/plugins/DLL32',exist_ok=True) - shutil.copy('../builds/_x86/shareddllproxy32.exe','../../py/files/plugins') - shutil.copy('../builds/_x86/winrtutils32.dll','../../py/files/plugins/DLL32') - shutil.copy('../builds/_x86/winsharedutils32.dll','../../py/files/plugins/DLL32') - shutil.copy('../builds/_x86/wcocr.dll','../../py/files/plugins/DLL32') - shutil.copy('../builds/_x86/LunaOCR32.dll','../../py/files/plugins/DLL32') - os.makedirs('../../py/files/plugins/DLL64',exist_ok=True) - shutil.copy('../builds/_x64/shareddllproxy64.exe','../../py/files/plugins') - shutil.copy('../builds/_x64/hookmagpie.dll','../../py/files/plugins') - shutil.copy('../builds/_x64/winrtutils64.dll','../../py/files/plugins/DLL64') - shutil.copy('../builds/_x64/winsharedutils64.dll','../../py/files/plugins/DLL64') - shutil.copy('../builds/_x64/wcocr.dll','../../py/files/plugins/DLL64') - shutil.copy('../builds/_x64/LunaOCR64.dll','../../py/files/plugins/DLL64') - + os.makedirs("../../py/files/plugins/DLL32", exist_ok=True) + shutil.copy("../builds/_x86/shareddllproxy32.exe", "../../py/files/plugins") + shutil.copy("../builds/_x86/winrtutils32.dll", "../../py/files/plugins/DLL32") + shutil.copy( + "../builds/_x86/winsharedutils32.dll", "../../py/files/plugins/DLL32" + ) + shutil.copy("../builds/_x86/wcocr.dll", "../../py/files/plugins/DLL32") + shutil.copy("../builds/_x86/LunaOCR32.dll", "../../py/files/plugins/DLL32") + os.makedirs("../../py/files/plugins/DLL64", exist_ok=True) + shutil.copy("../builds/_x64/shareddllproxy64.exe", "../../py/files/plugins") + shutil.copy("../builds/_x64/hookmagpie.dll", "../../py/files/plugins") + shutil.copy("../builds/_x64/winrtutils64.dll", "../../py/files/plugins/DLL64") + shutil.copy( + "../builds/_x64/winsharedutils64.dll", "../../py/files/plugins/DLL64" + ) + shutil.copy("../builds/_x64/wcocr.dll", "../../py/files/plugins/DLL64") + shutil.copy("../builds/_x64/LunaOCR64.dll", "../../py/files/plugins/DLL64") + if arch == "x86": os.chdir(rootDir) os.system(f"python {os.path.join(rootthisfiledir,'collectall.py')} 32") diff --git a/.github/workflows/buildluna.yml b/.github/workflows/buildluna.yml index 68905e38..421d1cea 100644 --- a/.github/workflows/buildluna.yml +++ b/.github/workflows/buildluna.yml @@ -73,6 +73,8 @@ jobs: fname: LunaTranslator steps: - uses: actions/checkout@v4 + - run: git submodule init py/files/LunaTranslator_qss + - run: git submodule update py/files/LunaTranslator_qss - uses: actions/download-artifact@v4 with: path: build diff --git a/py/LunaTranslator/LunaTranslator.py b/py/LunaTranslator/LunaTranslator.py index 684170a3..84c08cc1 100644 --- a/py/LunaTranslator/LunaTranslator.py +++ b/py/LunaTranslator/LunaTranslator.py @@ -1026,11 +1026,11 @@ class MAINUI: if _fn.endswith(".py"): style = importlib.import_module( - "files.themes." + _fn[:-3].replace("/", ".") + "files.LunaTranslator_qss." + _fn[:-3].replace("/", ".") ).stylesheet() elif _fn.endswith(".qss"): with open( - "./files/themes/{}".format(_fn), + "./files/LunaTranslator_qss/{}".format(_fn), "r", ) as ff: style = ff.read() diff --git a/py/files/themes/.keepdir b/py/files/themes/.keepdir deleted file mode 100644 index e69de29b..00000000