mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-19 09:10:18 +00:00
Compare commits
4 Commits
381f27db87
...
51e15c68e0
Author | SHA1 | Date | |
---|---|---|---|
51e15c68e0 | |||
00f680edd3 | |||
7dee8114bf | |||
90e66a43fe |
113
prebuild.py
113
prebuild.py
@ -1,70 +1,87 @@
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
from importlib import metadata
|
||||
from pathlib import Path
|
||||
|
||||
# fill VERSION file
|
||||
versionFile = Path("ui/resources/VERSION")
|
||||
assert versionFile.exists()
|
||||
|
||||
versionTexts = []
|
||||
def getGitDesc():
|
||||
gitDescribe = subprocess.run(
|
||||
["git", "describe", "--tags", "--long"],
|
||||
capture_output=True,
|
||||
encoding="utf-8",
|
||||
)
|
||||
if gitDescribe.returncode == 0:
|
||||
return gitDescribe.stdout.replace("\n", "")
|
||||
|
||||
projectVersionText = "arcaea-offline-pyside-ui\n"
|
||||
gitDescribe = os.popen("git describe --tags --long")
|
||||
gitDescribeContent = gitDescribe.read().replace("\n", "")
|
||||
if gitDescribe.close() is None:
|
||||
projectVersionText += f"{gitDescribeContent}"
|
||||
else:
|
||||
gitRevParse = os.popen("git rev-parse --short HEAD")
|
||||
gitRevParseContent = gitRevParse.read().replace("\n", "")
|
||||
projectVersionText += f"commit {gitRevParseContent}"
|
||||
gitRevParse.close()
|
||||
projectVersionText += "\n"
|
||||
# describe failed, try rev-parse
|
||||
gitRevParse = subprocess.run(
|
||||
["git", "rev-parse", "--short", "HEAD"],
|
||||
capture_output=True,
|
||||
encoding="utf-8",
|
||||
)
|
||||
if gitRevParse.returncode == 0:
|
||||
return f"commit {gitRevParse.stdout}".replace("\n", "")
|
||||
|
||||
versionTexts.append(projectVersionText)
|
||||
return "version/commit unknown"
|
||||
|
||||
|
||||
# detect pip
|
||||
pipName = None
|
||||
possiblePipNames = ["pip3", "pip"]
|
||||
for possiblePipName in possiblePipNames:
|
||||
result = os.popen(possiblePipName).read()
|
||||
if (
|
||||
"<command> [options]" in result
|
||||
and "install" in result
|
||||
and "--upgrade" in result
|
||||
):
|
||||
pipName = possiblePipName
|
||||
break
|
||||
def getBuildToolsVer():
|
||||
texts = []
|
||||
possibleBuildTools = ["Nuitka", "pyinstaller"]
|
||||
for possibleBuildTool in possibleBuildTools:
|
||||
try:
|
||||
version = metadata.version(possibleBuildTool)
|
||||
texts.append(f"{possibleBuildTool}=={version}")
|
||||
except metadata.PackageNotFoundError:
|
||||
texts.append(f"{possibleBuildTool} not installed")
|
||||
return ", ".join(texts)
|
||||
|
||||
|
||||
# if possiblePipName:
|
||||
# pipFreezeLines = os.popen(f"{possiblePipName} freeze").read().split("\n")
|
||||
# text = [
|
||||
# pipFreezeResult
|
||||
# for pipFreezeResult in pipFreezeLines
|
||||
# if (
|
||||
# "arcaea-offline" in pipFreezeResult
|
||||
# or "PySide6" in pipFreezeResult
|
||||
# or "exif" in pipFreezeResult
|
||||
# or "opencv-python" in pipFreezeResult
|
||||
# or "SQLAlchemy" in pipFreezeResult
|
||||
# )
|
||||
# ]
|
||||
# versionTexts.append("\n".join(text))
|
||||
def writeVersionFile():
|
||||
versionFile = Path("ui/resources/VERSION")
|
||||
assert versionFile.exists()
|
||||
|
||||
importLibTexts = [
|
||||
versionText = (
|
||||
"arcaea-offline-pyside-ui\n{gitDesc}\n{buildToolsVer}\n\n"
|
||||
"{pythonVer}\n\n"
|
||||
"{depsVer}\n"
|
||||
)
|
||||
|
||||
gitDesc = getGitDesc()
|
||||
buildToolsVer = getBuildToolsVer()
|
||||
|
||||
pythonVer = f"{platform.python_implementation()} {platform.python_version()} ({platform.python_build()[0]})"
|
||||
|
||||
importLibTexts = [
|
||||
f"{module}=={metadata.version(module)}"
|
||||
for module in [
|
||||
for module in sorted(
|
||||
[
|
||||
"arcaea-offline",
|
||||
"arcaea-offline-ocr",
|
||||
"exif",
|
||||
"numpy",
|
||||
"opencv-python",
|
||||
"Pillow",
|
||||
"PySide6",
|
||||
"SQLAlchemy",
|
||||
"SQLAlchemy-Utils",
|
||||
"Whoosh",
|
||||
],
|
||||
key=lambda s: s.lower(),
|
||||
)
|
||||
]
|
||||
]
|
||||
versionTexts.append("\n".join(importLibTexts))
|
||||
importLibText = "\n".join(importLibTexts)
|
||||
|
||||
with versionFile.open("w", encoding="utf-8") as vf:
|
||||
vf.write("\n".join(versionTexts))
|
||||
with versionFile.open("w", encoding="utf-8") as vf:
|
||||
vf.write(
|
||||
versionText.format(
|
||||
gitDesc=gitDesc,
|
||||
buildToolsVer=buildToolsVer,
|
||||
pythonVer=pythonVer,
|
||||
depsVer=importLibText,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
writeVersionFile()
|
||||
|
@ -1,2 +1,4 @@
|
||||
black == 23.7.0
|
||||
isort == 5.12.0
|
||||
imageio==2.31.4
|
||||
Nuitka==1.8.4
|
||||
|
@ -7,7 +7,7 @@ import numpy as np
|
||||
from arcaea_offline_ocr.phash_db import phash_opencv
|
||||
|
||||
|
||||
def preprocess_char_icon(img_gray: cv2.Mat):
|
||||
def preprocess_char_icon(img_gray: np.ndarray):
|
||||
h, w = img_gray.shape[:2]
|
||||
img = cv2.fillPoly(
|
||||
img_gray,
|
||||
@ -23,7 +23,7 @@ def preprocess_char_icon(img_gray: cv2.Mat):
|
||||
|
||||
|
||||
def build_image_phash_database(
|
||||
images: list[cv2.Mat],
|
||||
images: list[np.ndarray],
|
||||
labels: list[str],
|
||||
*,
|
||||
hash_size: int = 16,
|
||||
|
@ -31,6 +31,9 @@ class AndrealExecuteRunnable(QRunnable):
|
||||
encoding="utf-8",
|
||||
)
|
||||
result = subp.stdout
|
||||
if subp.returncode != 0:
|
||||
logger.error("AndrealImageGenerator Error: ")
|
||||
logger.error(result)
|
||||
b64Result = [s for s in result.split("\n") if s]
|
||||
imageBytes = base64.b64decode(
|
||||
re.sub(r"data:image/.*;base64,", "", b64Result[-1])
|
||||
|
Loading…
x
Reference in New Issue
Block a user