GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pearipherals/scripts/write_version_info.py at main · OnlineFix/Pearipherals

Expand file tree

/

write_version_info.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
67 lines (56 loc) · 2.08 KB
/

write_version_info.py

Copy path

File metadata and controls

67 lines (56 loc) · 2.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Generate deterministic Windows version metadata for the frozen executable."""
from __future__ import annotations
import argparse
import re
from pathlib import Path
VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?$")
def normalize_version(value: str) -> tuple[int, int, int, int]:
match = VERSION_RE.fullmatch(value.strip().removeprefix("v"))
if not match:
raise ValueError("version must be v?MAJOR.MINOR.PATCH[.BUILD]")
parts = [int(part or 0) for part in match.groups()]
if any(part > 65535 for part in parts):
raise ValueError("Windows version components must be between 0 and 65535")
return tuple(parts) # type: ignore[return-value]
def render(version: tuple[int, int, int, int]) -> str:
numeric = ", ".join(map(str, version))
display = ".".join(map(str, version[:3]))
return f"""# UTF-8
VSVersionInfo(
ffi=FixedFileInfo(
filevers=({numeric}),
prodvers=({numeric}),
mask=0x3f,
flags=0x0,
OS=0x40004,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo([
StringTable(
'040904B0',
[StringStruct('CompanyName', 'Pearipherals open-source project'),
StringStruct('FileDescription', 'Pearipherals for Apple input devices on Windows'),
StringStruct('FileVersion', '{display}'),
StringStruct('InternalName', 'Pearipherals'),
StringStruct('LegalCopyright', 'Copyright Pearipherals contributors; MIT License'),
StringStruct('OriginalFilename', 'Pearipherals.exe'),
StringStruct('ProductName', 'Pearipherals'),
StringStruct('ProductVersion', '{display}')])
]),
VarFileInfo([VarStruct('Translation', [1033, 1200])])
]
)
"""
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("version")
parser.add_argument("output", type=Path)
args = parser.parse_args()
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(render(normalize_version(args.version)), encoding="utf-8", newline="\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.