Skip to content

Commit

Permalink
exe version & other details processing by pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Dec 22, 2023
1 parent 17c4615 commit 896fd43
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/pyinstaller.run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

@echo.
@echo running-pyinstaller-stage_librer
pyinstaller --noconfirm --clean --add-data="distro.info.txt:." --add-data="version.txt;." --add-data="../LICENSE;." --icon=icon.ico --distpath=%OUTDIR% --windowed --contents-directory=internal librer.py || exit /b 2
pyinstaller --version-file=version.pi.librer.txt --noconfirm --clean --add-data="distro.info.txt:." --add-data="version.txt;." --add-data="../LICENSE;." --icon=icon.ico --distpath=%OUTDIR% --windowed --contents-directory=internal librer.py || exit /b 2

@echo.
@echo running-pyinstaller-stage_record
pyinstaller --noconfirm --clean --add-data="distro.info.txt:." --add-data="version.txt;." --add-data="../LICENSE;." --icon=icon.ico --distpath=%OUTDIR% --console --hide-console hide-early --contents-directory=internal record.py || exit /b 1
pyinstaller --version-file=version.pi.record.txt --noconfirm --clean --add-data="distro.info.txt:." --add-data="version.txt;." --add-data="../LICENSE;." --icon=icon.ico --distpath=%OUTDIR% --console --hide-console hide-early --contents-directory=internal record.py || exit /b 1

move %OUTDIR%\record\record.exe %OUTDIR%\librer

Expand Down
43 changes: 43 additions & 0 deletions src/version.pi.template.librer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(0, 0, 0, 0),
prodvers=(0, 0, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(1000, 1001)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904b0',
[StringStruct(u'CompanyName', u'https://github.com/PJDude/librer'),
StringStruct(u'FileDescription', u'Librer'),
StringStruct(u'FileVersion', u'0.0.0.0'),
StringStruct(u'InternalName', u'Librer'),
StringStruct(u'LegalCopyright', u'Piotr Jochymek 2023'),
StringStruct(u'OriginalFilename', u'librer.exe'),
StringStruct(u'ProductName', u'Librer'),
StringStruct(u'ProductVersion', u'VER_TO_REPLACE')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)
43 changes: 43 additions & 0 deletions src/version.pi.template.record.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(0, 0, 0, 0),
prodvers=(0, 0, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(1000, 1001)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904b0',
[StringStruct(u'CompanyName', u'https://github.com/PJDude/librer'),
StringStruct(u'FileDescription', u'Librer-Record'),
StringStruct(u'FileVersion', u'0.0.0.0'),
StringStruct(u'InternalName', u'record'),
StringStruct(u'LegalCopyright', u'Piotr Jochymek 2023'),
StringStruct(u'OriginalFilename', u'record.exe'),
StringStruct(u'ProductName', u'Librer-Record'),
StringStruct(u'ProductVersion', u'VER_TO_REPLACE')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)
10 changes: 8 additions & 2 deletions src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

####################################################################################
#
# Copyright (c) 2022-2023 Piotr Jochymek
# Copyright (c) 2023 Piotr Jochymek
#
# MIT License
#
Expand Down Expand Up @@ -49,8 +49,14 @@
time_diff_days_str=str(time_diff_days).zfill(4)
mins_rest_by2_str=str(round(mins_rest/2)).zfill(3)

version='v%s.%s.%s' % (MAIN_VERSION,time_diff_days_str,mins_rest_by2_str)
ver_num = '%s.%s.%s' % (MAIN_VERSION,time_diff_days_str,mins_rest_by2_str)
version='v%s' % ver_num
with open(VERSION_FILE,'w' ) as f:
f.write(version)

for template,result in (('version.pi.template.librer.txt','version.pi.librer.txt'),('version.pi.template.record.txt','version.pi.record.txt')):
with open(template,'r' ) as fr:
with open(result,'w' ) as f:
f.write(fr.read().replace('VER_TO_REPLACE',ver_num))

print(version)

0 comments on commit 896fd43

Please sign in to comment.