feat: add complete yiyezhqiu productivity suite
This commit is contained in:
commit
e422ca8b2a
155 files changed
+18959
No files matched your search
@@ -0,0 +1,57 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||
|
||||
|
||||
ROOT = Path(SPEC).resolve().parent.parent
|
||||
hiddenimports = (
|
||||
collect_submodules("dx_productivity")
|
||||
+ collect_submodules("qtawesome")
|
||||
+ collect_submodules("cryptography")
|
||||
)
|
||||
datas = collect_data_files("qtawesome")
|
||||
|
||||
a = Analysis(
|
||||
[str(ROOT / "src" / "dx_productivity" / "bridge" / "launcher.py")],
|
||||
pathex=[str(ROOT / "src")],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name="DxDesignerTools",
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
contents_directory="_runtime",
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name="DxDesignerTools",
|
||||
)
|
||||
@@ -0,0 +1,162 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$buildRoot = Join-Path $repoRoot "build\pyinstaller"
|
||||
$distRoot = Join-Path $repoRoot "dist\DxDesignerTools"
|
||||
$releaseBase = Join-Path $repoRoot "release"
|
||||
$releaseRoot = Join-Path $releaseBase "DxDesigner效率工具"
|
||||
$archivePath = Join-Path $releaseBase "DxDesigner效率工具_Win11_x64.zip"
|
||||
$manifestPath = Join-Path $releaseBase "SHA256SUMS.txt"
|
||||
$versionFile = Join-Path $releaseRoot "version.json"
|
||||
$updateManifestFile = Join-Path $releaseRoot "update-manifest.template.json"
|
||||
|
||||
function Assert-RepositoryChild {
|
||||
param([Parameter(Mandatory = $true)][string]$Path)
|
||||
$fullPath = [IO.Path]::GetFullPath($Path)
|
||||
$fullRoot = [IO.Path]::GetFullPath($repoRoot).TrimEnd('\') + '\'
|
||||
if (-not $fullPath.StartsWith($fullRoot, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
throw "Refusing to modify path outside repository: $fullPath"
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($path in @($buildRoot, $distRoot, $releaseRoot, $archivePath, $manifestPath)) {
|
||||
Assert-RepositoryChild -Path $path
|
||||
}
|
||||
|
||||
$pythonInfo = & py -3.12 -c "import struct,sys; print(str(sys.version_info.major)+'.'+str(sys.version_info.minor)+'|'+str(struct.calcsize('P')*8))"
|
||||
if ($LASTEXITCODE -ne 0 -or $pythonInfo.Trim() -ne "3.12|64") {
|
||||
throw "Build requires 64-bit Python 3.12."
|
||||
}
|
||||
$pythonExe = (& py -3.12 -c "import sys; print(sys.executable)").Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $pythonExe -PathType Leaf)) {
|
||||
throw "Could not resolve the Python 3.12 executable."
|
||||
}
|
||||
|
||||
& $pythonExe -c "import PyInstaller, PySide6, qtawesome"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Build dependencies are missing. Install the project build extras before running this script."
|
||||
}
|
||||
|
||||
foreach ($path in @($buildRoot, $distRoot, $releaseRoot)) {
|
||||
if (Test-Path -LiteralPath $path) {
|
||||
Remove-Item -LiteralPath $path -Recurse -Force
|
||||
}
|
||||
}
|
||||
foreach ($path in @($archivePath, $manifestPath)) {
|
||||
if (Test-Path -LiteralPath $path) {
|
||||
Remove-Item -LiteralPath $path -Force
|
||||
}
|
||||
}
|
||||
New-Item -ItemType Directory -Path $releaseBase -Force | Out-Null
|
||||
|
||||
$pyInstallerArgs = @(
|
||||
"-m", "PyInstaller", "--noconfirm", "--clean",
|
||||
"--workpath", $buildRoot,
|
||||
"--distpath", (Split-Path -Parent $distRoot),
|
||||
(Join-Path $PSScriptRoot "DxDesignerTools.spec")
|
||||
)
|
||||
$pythonRoot = Split-Path -Parent $pythonExe
|
||||
$windowsRoot = if ([string]::IsNullOrWhiteSpace($env:WINDIR)) { "C:\Windows" } else { $env:WINDIR }
|
||||
$buildPath = @(
|
||||
$pythonRoot,
|
||||
(Join-Path $pythonRoot "Scripts"),
|
||||
(Join-Path $windowsRoot "System32"),
|
||||
$windowsRoot,
|
||||
(Join-Path $windowsRoot "System32\Wbem")
|
||||
) -join ";"
|
||||
$originalPath = $env:PATH
|
||||
try {
|
||||
$env:PATH = $buildPath
|
||||
& $pythonExe @pyInstallerArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "PyInstaller build failed."
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$env:PATH = $originalPath
|
||||
}
|
||||
|
||||
Copy-Item -LiteralPath $distRoot -Destination $releaseRoot -Recurse
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\MenuAdd.vbs") -Destination (Join-Path $releaseRoot "MenuAdd.vbs")
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\DesignBridge.vbs") -Destination (Join-Path $releaseRoot "DesignBridge.vbs")
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\CompatibilityProbe.vbs") -Destination (Join-Path $releaseRoot "CompatibilityProbe.vbs")
|
||||
|
||||
$runtimeVbs = Join-Path $releaseRoot "_runtime\vbs"
|
||||
New-Item -ItemType Directory -Path $runtimeVbs -Force | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\BridgeCommon.vbs") -Destination (Join-Path $runtimeVbs "BridgeCommon.vbs")
|
||||
$coreSource = Join-Path $repoRoot "integration\dxdesigner795\core"
|
||||
New-Item -ItemType Directory -Path $runtimeVbs -Force | Out-Null
|
||||
Copy-Item -Path (Join-Path $coreSource "*.vbs") -Destination $runtimeVbs
|
||||
|
||||
$expeditionRoot = Join-Path $releaseRoot "expedition"
|
||||
New-Item -ItemType Directory -Path $expeditionRoot -Force | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\expedition\ExpeditionBridge.vbs") -Destination (Join-Path $expeditionRoot "ExpeditionBridge.vbs")
|
||||
|
||||
$templatesRoot = Join-Path $releaseRoot "templates"
|
||||
New-Item -ItemType Directory -Path $templatesRoot -Force | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $repoRoot "integration\dxdesigner795\templates\BOM模板.xls") -Destination (Join-Path $templatesRoot "BOM模板.xls")
|
||||
|
||||
$docsRoot = Join-Path $releaseRoot "docs"
|
||||
New-Item -ItemType Directory -Path $docsRoot -Force | Out-Null
|
||||
$guideSource = Join-Path $repoRoot "docs\user\DxDesigner_7.9.5_自动位号工具使用说明_v0.5.docx"
|
||||
$guideDestination = Join-Path $docsRoot "DxDesigner_7.9.5_自动位号工具使用说明.docx"
|
||||
Copy-Item -LiteralPath $guideSource -Destination $guideDestination
|
||||
|
||||
$env:PYTHONPATH = Join-Path $repoRoot "src"
|
||||
$productVersion = (& $pythonExe -c "import dx_productivity; print(dx_productivity.__version__)").Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($productVersion)) {
|
||||
throw "Could not read dx_productivity.__version__ from the source tree."
|
||||
}
|
||||
Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue
|
||||
$versionPayload = [ordered]@{
|
||||
product = "yiyezhqiu-refactored"
|
||||
display_name = "一叶知秋_重构版"
|
||||
version = $productVersion
|
||||
}
|
||||
[IO.File]::WriteAllText($versionFile, ($versionPayload | ConvertTo-Json), [Text.UTF8Encoding]::new($false))
|
||||
$updatePayload = [ordered]@{
|
||||
product = "yiyezhqiu-refactored"
|
||||
version = $productVersion
|
||||
channel = "stable"
|
||||
min_supported_version = "0.1.0"
|
||||
package_url = ""
|
||||
sha256 = ""
|
||||
release_notes = ""
|
||||
published_at = (Get-Date).ToUniversalTime().ToString("yyyy-MM-dd")
|
||||
signature = ""
|
||||
}
|
||||
[IO.File]::WriteAllText($updateManifestFile, ($updatePayload | ConvertTo-Json), [Text.UTF8Encoding]::new($false))
|
||||
|
||||
$expected = @(
|
||||
(Join-Path $releaseRoot "DxDesignerTools.exe"),
|
||||
(Join-Path $releaseRoot "_runtime\python312.dll"),
|
||||
(Join-Path $releaseRoot "MenuAdd.vbs"),
|
||||
(Join-Path $releaseRoot "DesignBridge.vbs"),
|
||||
(Join-Path $releaseRoot "CompatibilityProbe.vbs"),
|
||||
(Join-Path $releaseRoot "_runtime\vbs\BridgeCommon.vbs"),
|
||||
(Join-Path $releaseRoot "_runtime\vbs\Snapshot.vbs"),
|
||||
(Join-Path $releaseRoot "_runtime\vbs\Transaction.vbs"),
|
||||
(Join-Path $releaseRoot "_runtime\vbs\Mailbox.vbs"),
|
||||
(Join-Path $releaseRoot "_runtime\vbs\BomExport.vbs"),
|
||||
(Join-Path $releaseRoot "templates\BOM模板.xls"),
|
||||
(Join-Path $releaseRoot "expedition\ExpeditionBridge.vbs"),
|
||||
(Join-Path $docsRoot "DxDesigner_7.9.5_自动位号工具使用说明.docx"),
|
||||
$versionFile,
|
||||
$updateManifestFile
|
||||
)
|
||||
foreach ($path in $expected) {
|
||||
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
|
||||
throw "Release file is missing: $path"
|
||||
}
|
||||
}
|
||||
|
||||
Compress-Archive -LiteralPath $releaseRoot -DestinationPath $archivePath -CompressionLevel Optimal
|
||||
$archiveHash = (Get-FileHash -LiteralPath $archivePath -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
$manifest = "$archiveHash *DxDesigner效率工具_Win11_x64.zip" + [Environment]::NewLine
|
||||
[IO.File]::WriteAllText($manifestPath, $manifest, [Text.UTF8Encoding]::new($false))
|
||||
|
||||
Write-Output "RELEASE_ROOT=$releaseRoot"
|
||||
Write-Output "ARCHIVE=$archivePath"
|
||||
Write-Output "SHA256=$archiveHash"
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Sign a release archive and produce the manifest signature field.
|
||||
|
||||
Workflow (offline, on the machine holding the private key):
|
||||
|
||||
python packaging/sign_manifest.py --package dist/Bx.zip \
|
||||
--key ..\\signing\\yiyezhqiu-release-private-key.pem
|
||||
|
||||
Prints the base64 Ed25519 signature over the archive bytes. Paste it into
|
||||
``update-manifest.template.json``'s ``signature`` field (stable channel
|
||||
manifests must carry it; the client refuses unsigned stable updates).
|
||||
|
||||
NEVER copy the private key into the repository or the release package.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Sign an update archive")
|
||||
parser.add_argument("--package", type=Path, required=True)
|
||||
parser.add_argument("--key", type=Path, required=True)
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
options = build_parser().parse_args(argv)
|
||||
try:
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
|
||||
Ed25519PrivateKey,
|
||||
)
|
||||
except ImportError:
|
||||
print("cryptography is required: pip install cryptography", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
key_pem = options.key.read_bytes()
|
||||
private_key = serialization.load_pem_private_key(key_pem, password=None)
|
||||
if not isinstance(private_key, Ed25519PrivateKey):
|
||||
print("the key file is not an Ed25519 private key", file=sys.stderr)
|
||||
return 2
|
||||
signature = private_key.sign(options.package.read_bytes())
|
||||
print(base64.b64encode(signature).decode("ascii"))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user