Skip to content

Commit

Permalink
pyinstaller: include version info
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee authored Nov 18, 2024
1 parent 759f0cf commit f2e16c5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/gam.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ from PyInstaller.utils.hooks import copy_metadata

from gam.gamlib.glverlibs import GAM_VER_LIBS


with open("gam/__init__.py") as f:
version_file = f.read()
version = search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M).group(1)
version_tuple = "(" + version.split("-")[0].replace(".", ", ") + ", 0)"

with open("version_info.txt.in") as f:
version_info = f.read()
version_info = version_info.replace("{VERSION}", version).replace(
"{VERSION_TUPLE}", version_tuple
)
with open("version_info.txt", "w") as f:
f.write(version_info)
print(version_info)

datas = []
for pkg in GAM_VER_LIBS:
datas += copy_metadata(pkg, recursive=True)
Expand Down Expand Up @@ -51,6 +66,7 @@ target_arch = None
codesign_identity = None
entitlements_file = None
manifest = None
version = 'version_info.txt'
match platform:
case "darwin":
if getenv('arch') == 'universal2':
Expand Down Expand Up @@ -95,6 +111,7 @@ if getenv('PYINSTALLER_BUILD_ONEDIR') == 'yes':
target_arch=target_arch,
codesign_identity=codesign_identity,
entitlements_file=entitlements_file,
version=version,
)
coll = COLLECT(
exe,
Expand Down Expand Up @@ -127,5 +144,6 @@ else:
target_arch=target_arch,
codesign_identity=codesign_identity,
entitlements_file=entitlements_file,
version=version,
)

0 comments on commit f2e16c5

Please sign in to comment.