更新
This commit is contained in:
@@ -11,6 +11,7 @@ their platform media backends.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -23,9 +24,46 @@ RESOURCES = PROJECT_ROOT / "resources"
|
||||
WINDOWS_ICON = RESOURCES / "branding" / "app-icon.ico"
|
||||
MACOS_ICON = RESOURCES / "branding" / "app-icon.icns"
|
||||
ENTITLEMENTS = PROJECT_ROOT / "packaging" / "macos" / "entitlements.plist"
|
||||
VERSION_FILE = PROJECT_ROOT / "packaging" / "windows" / "version_info.txt"
|
||||
VERSION_SOURCE = SOURCE_ROOT / "doctor_workstation" / "__init__.py"
|
||||
VERSION_TEMPLATE = PROJECT_ROOT / "packaging" / "windows" / "version_info.template.txt"
|
||||
MEDIA_SMOKE_HOOK = PROJECT_ROOT / "packaging" / "runtime_media_smoke.py"
|
||||
|
||||
|
||||
def read_application_version():
|
||||
source = VERSION_SOURCE.read_text(encoding="utf-8")
|
||||
match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', source, re.MULTILINE)
|
||||
if not match:
|
||||
raise SystemExit(f"Application version is missing from {VERSION_SOURCE}")
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def windows_version_tuple(version):
|
||||
match = re.match(r"^(\d+(?:\.\d+){0,3})", version)
|
||||
if not match:
|
||||
raise SystemExit(f"Application version is invalid for Windows resources: {version}")
|
||||
parts = [int(part) for part in match.group(1).split(".")]
|
||||
return tuple((parts + [0, 0, 0, 0])[:4])
|
||||
|
||||
|
||||
def generate_windows_version_file(version):
|
||||
template = VERSION_TEMPLATE.read_text(encoding="utf-8")
|
||||
version_tuple = ", ".join(str(part) for part in windows_version_tuple(version))
|
||||
rendered = template.replace("@VERSION_TUPLE@", version_tuple)
|
||||
rendered = rendered.replace("@VERSION_STRING@", version)
|
||||
output = PROJECT_ROOT / "build" / "generated" / "version_info.txt"
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_text(rendered, encoding="utf-8")
|
||||
return output
|
||||
|
||||
|
||||
APP_VERSION = read_application_version()
|
||||
if sys.platform == "win32":
|
||||
if not VERSION_TEMPLATE.is_file():
|
||||
raise SystemExit(f"Windows version template is missing: {VERSION_TEMPLATE}")
|
||||
VERSION_FILE = generate_windows_version_file(APP_VERSION)
|
||||
else:
|
||||
VERSION_FILE = None
|
||||
|
||||
if not ENTRY_POINT.is_file():
|
||||
raise SystemExit(f"Application entry point is missing: {ENTRY_POINT}")
|
||||
if not (VIDEO_DIST / "index.html").is_file():
|
||||
@@ -107,7 +145,7 @@ exe = EXE(
|
||||
icon=str(WINDOWS_ICON) if sys.platform == "win32" else None,
|
||||
codesign_identity=os.environ.get("MACOS_CODESIGN_IDENTITY") if is_macos else None,
|
||||
entitlements_file=str(ENTITLEMENTS) if is_macos else None,
|
||||
version=str(VERSION_FILE) if sys.platform == "win32" else None,
|
||||
version=str(VERSION_FILE) if VERSION_FILE else None,
|
||||
)
|
||||
|
||||
collection = COLLECT(
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# UTF-8
|
||||
# Example PyInstaller version resource. Update all four version tuples together.
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
filevers=(0, 1, 0, 0),
|
||||
prodvers=(0, 1, 0, 0),
|
||||
mask=0x3f,
|
||||
flags=0x0,
|
||||
OS=0x40004,
|
||||
fileType=0x1,
|
||||
subtype=0x0,
|
||||
date=(0, 0)
|
||||
),
|
||||
kids=[
|
||||
StringFileInfo([
|
||||
StringTable(
|
||||
'080404B0',
|
||||
[
|
||||
StringStruct('CompanyName', 'ZYT'),
|
||||
StringStruct('FileDescription', '医生工作台'),
|
||||
StringStruct('FileVersion', '0.1.0.0'),
|
||||
StringStruct('InternalName', 'DoctorWorkstation'),
|
||||
StringStruct('OriginalFilename', 'DoctorWorkstation.exe'),
|
||||
StringStruct('ProductName', '医生工作台'),
|
||||
StringStruct('ProductVersion', '0.1.0.0')
|
||||
]
|
||||
)
|
||||
]),
|
||||
VarFileInfo([VarStruct('Translation', [2052, 1200])])
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user