|
| 1 | +import ast |
| 2 | +import os |
1 | 3 | import sys |
2 | 4 |
|
| 5 | + |
| 6 | +def read_app_version(root): |
| 7 | + """Return APP_VERSION from the app's config.py (leading 'v' stripped). |
| 8 | +
|
| 9 | + Parsed statically with ast -- config.py is never imported or executed, so |
| 10 | + there are no import side effects and no dependency on __file__ or the |
| 11 | + environment. build.py (deb/rpm version + banner) and the shared spec (macOS |
| 12 | + CFBundleShortVersionString) both call this, so every platform stamps the same |
| 13 | + manually-maintained version from config.py and no CI/tag value is used. |
| 14 | + """ |
| 15 | + path = os.path.join(str(root), "config.py") |
| 16 | + with open(path, encoding="utf-8") as fh: |
| 17 | + tree = ast.parse(fh.read(), filename=path) |
| 18 | + for node in tree.body: |
| 19 | + if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant): |
| 20 | + for target in node.targets: |
| 21 | + if isinstance(target, ast.Name) and target.id == "APP_VERSION": |
| 22 | + value = str(node.value.value) |
| 23 | + return value[1:] if value.startswith("v") else value |
| 24 | + return "0.0.0" |
| 25 | + |
| 26 | + |
3 | 27 | PLATFORMS = { |
4 | 28 | "windows": { |
5 | 29 | "launcher": "windows/launcher.py", |
|
38 | 62 | "NSHighResolutionCapable": True, |
39 | 63 | "CFBundleName": "AudioMuse-AI", |
40 | 64 | "CFBundleDisplayName": "AudioMuse-AI", |
41 | | - "CFBundleShortVersionString": "1.0.0", |
42 | 65 | }, |
43 | 66 | }, |
44 | 67 | }, |
|
0 commit comments