mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-15 08:53:53 +08:00
actions (#1128)
This commit is contained in:
parent
83af7fca61
commit
f004380daf
65
.github/workflows/build.yml
vendored
65
.github/workflows/build.yml
vendored
@ -7,8 +7,46 @@ on:
|
|||||||
paths: [ '.github/workflows/build.yml','src/**']
|
paths: [ '.github/workflows/build.yml','src/**']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
pyrt:
|
||||||
runs-on: windows-latest
|
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:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@ -17,27 +55,12 @@ jobs:
|
|||||||
- architecture: x64
|
- architecture: x64
|
||||||
fname: LunaTranslator
|
fname: LunaTranslator
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: actions/download-artifact@v4
|
||||||
- name: Setup Windows 10 SDK
|
|
||||||
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
|
|
||||||
with:
|
with:
|
||||||
sdk-version: 22621
|
path: build
|
||||||
- name: Install Python
|
- run: python src/build.py merge ${{ matrix.architecture }}
|
||||||
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
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.fname }}
|
name: ${{ matrix.fname }}
|
||||||
path: src/build/${{ matrix.fname }}.zip
|
path: src/build/${{matrix.fname}}.zip
|
94
.github/workflows/release.yml
vendored
94
.github/workflows/release.yml
vendored
@ -4,8 +4,55 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
loadversion:
|
||||||
runs-on: windows-latest
|
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:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@ -13,47 +60,16 @@ jobs:
|
|||||||
fname: LunaTranslator_x86
|
fname: LunaTranslator_x86
|
||||||
- architecture: x64
|
- architecture: x64
|
||||||
fname: LunaTranslator
|
fname: LunaTranslator
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
attestations: write
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: actions/download-artifact@v4
|
||||||
- name: Setup Windows 10 SDK
|
|
||||||
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
|
|
||||||
with:
|
with:
|
||||||
sdk-version: 22621
|
path: build
|
||||||
- name: Install Python
|
- run: python src/build.py merge ${{ matrix.architecture }}
|
||||||
uses: actions/setup-python@v5
|
- uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.7.9'
|
tag_name: ${{ needs.loadversion.outputs.version }}
|
||||||
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 }}
|
|
||||||
files: |
|
files: |
|
||||||
src/build/${{ matrix.fname }}.zip
|
src/build/${{matrix.fname}}.zip
|
||||||
src/build/${{ matrix.fname }}.exe
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -22,8 +22,8 @@ def prepareqtenv():
|
|||||||
import windows
|
import windows
|
||||||
|
|
||||||
# win7 no vcredist2015
|
# win7 no vcredist2015
|
||||||
windows.addenvpath("./LunaTranslator/runtime/")
|
windows.addenvpath("./files/runtime/")
|
||||||
windows.loadlibrary("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll")
|
windows.loadlibrary("./files/runtime/PyQt5/Qt5/bin/Qt5Core.dll")
|
||||||
|
|
||||||
from qtsymbols import QApplication, isqt5, Qt, QFont, QLocale
|
from qtsymbols import QApplication, isqt5, Qt, QFont, QLocale
|
||||||
|
|
||||||
@ -31,10 +31,10 @@ def prepareqtenv():
|
|||||||
|
|
||||||
if isqt5:
|
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_EnableHighDpiScaling)
|
||||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
|
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
|
# maybe use qwebengine
|
||||||
|
|
||||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
|
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
|
||||||
|
@ -45,7 +45,7 @@ def gettempdir(filename):
|
|||||||
|
|
||||||
|
|
||||||
def testuseqwebengine():
|
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
|
from LunaTranslator import MAINUI
|
||||||
|
@ -182,7 +182,7 @@ def doinstallqweb(self, dd, base):
|
|||||||
target = gobject.gettempdir("QWebEngine/")
|
target = gobject.gettempdir("QWebEngine/")
|
||||||
zipf.extractall(target)
|
zipf.extractall(target)
|
||||||
bit = ["x86", "x64"][platform.architecture()[0] == "64bit"]
|
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, "成功", "安装成功")
|
getQMessageBox(self, "成功", "安装成功")
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ from qtsymbols import *
|
|||||||
import os, platform, functools, uuid, json, math, csv, io, pickle
|
import os, platform, functools, uuid, json, math, csv, io, pickle
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import windows, qtawesome, winsharedutils, gobject
|
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 winsharedutils import HTMLBrowser
|
||||||
from myutils.config import _TR, globalconfig, _TRL
|
from myutils.config import _TR, globalconfig, _TRL
|
||||||
from myutils.wrapper import Singleton_close, tryprint
|
from myutils.wrapper import Singleton_close, tryprint
|
||||||
@ -1225,15 +1225,6 @@ class WebivewWidget(abstractwebview):
|
|||||||
|
|
||||||
def __init__(self, parent=None, debug=True, usedarklight=True) -> None:
|
def __init__(self, parent=None, debug=True, usedarklight=True) -> None:
|
||||||
super().__init__(parent)
|
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 = None
|
||||||
self.webview = Webview(debug=debug, window=int(self.winId()))
|
self.webview = Webview(debug=debug, window=int(self.winId()))
|
||||||
zoomfunc = winsharedutils.add_ZoomFactorChanged_CALLBACK(
|
zoomfunc = winsharedutils.add_ZoomFactorChanged_CALLBACK(
|
||||||
|
80
src/build.py
80
src/build.py
@ -5,6 +5,10 @@ import urllib.request
|
|||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
rootDir = os.path.dirname(__file__)
|
rootDir = os.path.dirname(__file__)
|
||||||
|
if not rootDir:
|
||||||
|
rootDir = os.path.abspath(".")
|
||||||
|
else:
|
||||||
|
rootDir = os.path.abspath(rootDir)
|
||||||
if sys.argv[1] == "loadversion":
|
if sys.argv[1] == "loadversion":
|
||||||
os.chdir(rootDir)
|
os.chdir(rootDir)
|
||||||
with open("plugins/CMakeLists.txt", "r", encoding="utf8") as ff:
|
with open("plugins/CMakeLists.txt", "r", encoding="utf8") as ff:
|
||||||
@ -15,6 +19,10 @@ if sys.argv[1] == "loadversion":
|
|||||||
print("version=" + versionstring)
|
print("version=" + versionstring)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
print(sys.version)
|
||||||
|
print(__file__)
|
||||||
|
print(rootDir)
|
||||||
|
|
||||||
mylinks = {
|
mylinks = {
|
||||||
"LunaHook": "https://github.com/HIllya51/LunaHook/releases/latest/download/Release_English.zip",
|
"LunaHook": "https://github.com/HIllya51/LunaHook/releases/latest/download/Release_English.zip",
|
||||||
"ocr_models": {
|
"ocr_models": {
|
||||||
@ -188,7 +196,7 @@ def get_url_as_json(url):
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
||||||
def buildLunaHook():
|
def downLunaHook():
|
||||||
|
|
||||||
os.chdir(rootDir + "\\temp")
|
os.chdir(rootDir + "\\temp")
|
||||||
LunaHook_latest = mylinks["LunaHook"]
|
LunaHook_latest = mylinks["LunaHook"]
|
||||||
@ -212,23 +220,25 @@ def buildLunaHook():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def buildPlugins():
|
def buildPlugins(arch):
|
||||||
os.chdir(rootDir + "\\plugins\\scripts")
|
os.chdir(rootDir + "\\plugins\\scripts")
|
||||||
subprocess.run("python fetchwebview2.py")
|
subprocess.run("python fetchwebview2.py")
|
||||||
|
if arch == "x86":
|
||||||
subprocess.run(
|
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'
|
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(
|
subprocess.run(
|
||||||
f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14"
|
f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14"
|
||||||
)
|
)
|
||||||
subprocess.run(f"python copytarget.py 1")
|
# subprocess.run(f"python copytarget.py 1")
|
||||||
|
else:
|
||||||
subprocess.run(
|
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'
|
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(
|
subprocess.run(
|
||||||
f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14"
|
f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14"
|
||||||
)
|
)
|
||||||
subprocess.run(f"python copytarget.py 0")
|
# subprocess.run(f"python copytarget.py 0")
|
||||||
|
|
||||||
|
|
||||||
def downloadsomething():
|
def downloadsomething():
|
||||||
@ -254,12 +264,31 @@ def downloadbass():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
arch = sys.argv[1]
|
|
||||||
version = sys.argv[2]
|
|
||||||
os.chdir(rootDir)
|
os.chdir(rootDir)
|
||||||
os.system("git submodule update --init --recursive")
|
|
||||||
os.makedirs("temp", exist_ok=True)
|
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()
|
createPluginDirs()
|
||||||
downloadsomething()
|
downloadsomething()
|
||||||
downloadBrotli()
|
downloadBrotli()
|
||||||
@ -269,24 +298,25 @@ if __name__ == "__main__":
|
|||||||
downloadOCRModel()
|
downloadOCRModel()
|
||||||
downloadcommon()
|
downloadcommon()
|
||||||
downloadbass()
|
downloadbass()
|
||||||
buildLunaHook()
|
downLunaHook()
|
||||||
|
|
||||||
installVCLTL()
|
|
||||||
buildPlugins()
|
|
||||||
|
|
||||||
os.chdir(rootDir)
|
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")
|
||||||
|
|
||||||
if arch == "x86":
|
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)
|
os.chdir(rootDir)
|
||||||
|
os.system("python collectall.py 32")
|
||||||
subprocess.run(f"{py37Path} -m pip install --upgrade pip")
|
else:
|
||||||
subprocess.run(f"{py37Path} -m pip install -r requirements.txt")
|
os.chdir(rootDir)
|
||||||
# 3.8之后会莫名其妙引用这个b东西,然后这个b东西会把一堆没用的东西导入进来
|
os.system("python collectall.py 64")
|
||||||
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")
|
|
||||||
|
107
src/collectall.py
Normal file
107
src/collectall.py
Normal file
@ -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)
|
@ -1,34 +1,20 @@
|
|||||||
|
import os
|
||||||
import modulefinder, shutil, os, sys
|
import modulefinder, shutil, os, sys
|
||||||
import builtins, platform
|
import builtins, platform
|
||||||
import sys
|
import sys
|
||||||
from importanalysis import importanalysis
|
|
||||||
|
|
||||||
pyversion = platform.python_version()
|
pyversion = platform.python_version()
|
||||||
pyversion2 = "".join(pyversion.split(".")[:2])
|
pyversion2 = "".join(pyversion.split(".")[:2])
|
||||||
x86 = platform.architecture()[0] == "32bit"
|
x86 = platform.architecture()[0] == "32bit"
|
||||||
|
runtime = r"pyrt\runtime"
|
||||||
if x86:
|
if x86:
|
||||||
|
webviewpath = r"webviewpy\platform\win32\x86"
|
||||||
downlevel = r"C:\Windows\SysWOW64\downlevel"
|
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:
|
else:
|
||||||
baddll = "DLL32"
|
webviewpath = r"webviewpy\platform\win32\x64"
|
||||||
gooddll = "DLL64"
|
|
||||||
launch = r"plugins\builds\_x64"
|
|
||||||
runtime = r"build\LunaTranslator\LunaTranslator\runtime"
|
|
||||||
targetdir = r"build\LunaTranslator"
|
|
||||||
downlevel = r"C:\Windows\system32\downlevel"
|
downlevel = r"C:\Windows\system32\downlevel"
|
||||||
|
|
||||||
webviewappendix = r"Lib\site-packages\webviewpy\platform\win32\x64\webview.dll"
|
|
||||||
|
|
||||||
py37Path = os.path.dirname(sys.executable)
|
py37Path = os.path.dirname(sys.executable)
|
||||||
print(py37Path)
|
print(py37Path)
|
||||||
py37Pathwebview = os.path.join(py37Path, webviewappendix)
|
|
||||||
|
|
||||||
|
|
||||||
def get_dependencies(filename):
|
def get_dependencies(filename):
|
||||||
@ -73,20 +59,6 @@ def copycheck(src, tgt):
|
|||||||
shutil.copy(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()
|
all_dependencies = set()
|
||||||
for _d, _, _fs in os.walk("./LunaTranslator"):
|
for _d, _, _fs in os.walk("./LunaTranslator"):
|
||||||
for f in _fs:
|
for f in _fs:
|
||||||
@ -128,7 +100,6 @@ for dependency in all_dependencies:
|
|||||||
tgtreal = os.path.join(runtime, os.path.dirname(end))
|
tgtreal = os.path.join(runtime, os.path.dirname(end))
|
||||||
copycheck(dependency, tgtreal)
|
copycheck(dependency, tgtreal)
|
||||||
|
|
||||||
|
|
||||||
with open(os.path.join(runtime, f"python{pyversion2}._pth"), "w") as ff:
|
with open(os.path.join(runtime, f"python{pyversion2}._pth"), "w") as ff:
|
||||||
ff.write("..\n.")
|
ff.write("..\n.")
|
||||||
|
|
||||||
@ -141,6 +112,28 @@ copycheck(os.path.join(py37Path, "DLLs/libffi-7.dll"), runtime)
|
|||||||
|
|
||||||
|
|
||||||
copycheck(rf"{downlevel}\ucrtbase.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(
|
copycheck(
|
||||||
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/vcruntime140.dll"),
|
os.path.join(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/vcruntime140.dll"),
|
||||||
os.path.join(runtime),
|
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(py37Path, "Lib/site-packages/PyQt5/Qt5/bin/msvcp140_1.dll"),
|
||||||
os.path.join(runtime),
|
os.path.join(runtime),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
for _ in os.listdir(os.path.join(py37Path, "Lib/site-packages/PyQt5")):
|
for _ in os.listdir(os.path.join(py37Path, "Lib/site-packages/PyQt5")):
|
||||||
if _.startswith("sip"):
|
if _.startswith("sip"):
|
||||||
copycheck(
|
copycheck(
|
||||||
@ -204,64 +195,3 @@ copycheck(
|
|||||||
),
|
),
|
||||||
os.path.join(runtime, "PyQt5/Qt5/plugins/styles"),
|
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)
|
|
@ -1265,20 +1265,6 @@
|
|||||||
"link": "{main_server}/Resource/Magpie9_Win7"
|
"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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
|||||||
|
|
||||||
set(VERSION_MAJOR 5)
|
set(VERSION_MAJOR 5)
|
||||||
set(VERSION_MINOR 53)
|
set(VERSION_MINOR 53)
|
||||||
set(VERSION_PATCH 8)
|
set(VERSION_PATCH 9)
|
||||||
|
|
||||||
add_library(pch pch.cpp)
|
add_library(pch pch.cpp)
|
||||||
target_precompile_headers(pch PUBLIC pch.h)
|
target_precompile_headers(pch PUBLIC pch.h)
|
||||||
|
@ -339,7 +339,7 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto __handle = AutoHandle(CreateMutexA(&allAccess, FALSE, "LUNA_UPDATER_BLOCK"));
|
auto __handle = AutoHandle(CreateMutexA(&allAccess, FALSE, "LUNA_UPDATER_BLOCK"));
|
||||||
PyStand ps(L"LunaTranslator\\runtime");
|
PyStand ps(L"files\\runtime");
|
||||||
if (ps.DetectScript() != 0)
|
if (ps.DetectScript() != 0)
|
||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user