Skip to content

Commit e7db909

Browse files
committed
feat: dynamic versioning and bundled license support
- Enable reading version from core/version.txt with fallback to 1.0.0 - Update build workflow to generate version.txt from release tag - Bundle LICENSE and version.txt in PyInstaller builds - Fix license file path resolution for frozen executables (sys._MEIPASS)
1 parent 28abf43 commit e7db909

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

.github/workflows/build_release.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,22 @@ jobs:
9898
env:
9999
VERSION_TAG: ${{ needs.create_release.outputs.tag_name }}
100100
run: |
101-
pyinstaller --name WASP --onefile --windowed --add-data "core;core" --add-data "gui;gui" main.py
101+
# Create version file for dynamic versioning
102+
echo "${{ env.VERSION_TAG }}" > core/version.txt
103+
104+
pyinstaller --name WASP --onefile --windowed --add-data "core;core" --add-data "gui;gui" --add-data "LICENSE;." --add-data "core/version.txt;core" main.py
102105
mv dist/WASP.exe "dist/WASP-${{ env.VERSION_TAG }}-windows.exe"
103106
104107
- name: Build with PyInstaller (Linux - Binary, Deb, AppImage)
105108
if: runner.os == 'Linux'
106109
env:
107110
VERSION_TAG: ${{ needs.create_release.outputs.tag_name }}
108111
run: |
112+
# Create version file for dynamic versioning
113+
echo "${{ env.VERSION_TAG }}" > core/version.txt
114+
109115
# 1. Build Base Binary
110-
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" --hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg" main.py
116+
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" --add-data "LICENSE:." --add-data "core/version.txt:core" --hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg" main.py
111117
# Rename binary
112118
cp dist/WASP "dist/WASP-${{ env.VERSION_TAG }}-linux"
113119
@@ -162,7 +168,10 @@ jobs:
162168
env:
163169
VERSION_TAG: ${{ needs.create_release.outputs.tag_name }}
164170
run: |
165-
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" main.py
171+
# Create version file for dynamic versioning
172+
echo "${{ env.VERSION_TAG }}" > core/version.txt
173+
174+
pyinstaller --name WASP --onefile --windowed --add-data "core:core" --add-data "gui:gui" --add-data "LICENSE:." --add-data "core/version.txt:core" main.py
166175
167176
# 1. Zip the .app
168177
cd dist

core/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
VERSION = "1.0.0"
1+
import os
2+
3+
try:
4+
# Try to read the version from a file named 'version.txt' in the same directory
5+
version_file = os.path.join(os.path.dirname(__file__), "version.txt")
6+
if os.path.exists(version_file):
7+
with open(version_file, "r") as f:
8+
VERSION = f.read().strip()
9+
else:
10+
# Fallback version
11+
VERSION = "1.0.0"
12+
except Exception:
13+
VERSION = "1.0.0"

gui/about_tab.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ def add_info_row(label_text, value_text, is_link=False):
103103
}
104104
""")
105105
try:
106-
license_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "LICENSE")
106+
# Check for PyInstaller temporary directory (sys._MEIPASS)
107+
if hasattr(sys, '_MEIPASS'):
108+
base_path = sys._MEIPASS
109+
else:
110+
base_path = os.path.dirname(os.path.dirname(__file__))
111+
112+
license_path = os.path.join(base_path, "LICENSE")
113+
107114
if os.path.exists(license_path):
108115
with open(license_path, "r", encoding="utf-8") as f:
109116
self.license_text.setText(f.read())

output/main.exe

-46.6 MB
Binary file not shown.

0 commit comments

Comments
 (0)