-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用pyinstaller打包exe时生成hook以存储版本信息,改进检查更新时的文案提示
- Loading branch information
Showing
6 changed files
with
96 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# hook script generated for pyinstaller | ||
ver_hook.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import sys | ||
import subprocess | ||
|
||
run = subprocess.run(['git', 'describe', '--tags'], capture_output=True, encoding='utf-8') | ||
if run.returncode == 0: | ||
desc = run.stdout.strip() | ||
if '-' in desc: | ||
major, minor, _ = desc.split('-') | ||
auto_ver = major + '.' + minor | ||
else: # means current commit exactly matches the tag | ||
auto_ver = desc | ||
else: | ||
auto_ver = "v0.unknown" | ||
|
||
print('JavSP version: ' + auto_ver) | ||
|
||
hook_file = sys.argv[1] | ||
with open(hook_file, 'wt') as f: | ||
f.write('import sys\n') | ||
f.write("setattr(sys, 'javsp_version', '" + auto_ver + "')\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters