Open pemessier opened 2 weeks ago
... putting in my two cents ...
There is indeed a discrepancy. pyinstaller_versionfile validates the version to ensure compatibility with pyinstaller. A change to allow invalid string suffixes for pyinstaller would be a break with the actual usage specification. There are also other parameters in the Windows VERSIONINFO resource that are not supported here. It feels as if it would be worthwhile to write a separate tool - possibly from the existing one - which would write a Windows VERSIONINFO resource.
Thanks @pemessier for the proposal.
@truderung I built the validation to ensure compatibility with how I interpreted the official documentation. Unfortunately they are not very clear what format is allowed and what not.
If the end result works, I would be open to implement this change. But it has been a long time that I used pyinstaller myself, so if I am overlooking something, please let me know.
Hey @DudeNr33, your check is correct. This is what pyinstaller help tells:
In a Version resource there are two 64-bit binary values, FileVersion and ProductVersion. In the version text file these are given as four-element tuples, for example:
filevers=(2, 0, 4, 0), prodvers=(2, 0, 4, 0),
I also tried to violate the specification and have defined the ProductVersion as 1.2.3.dev, but pyinstaller failed in the bundling process:
File "C:\Users\viktor.truderung\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\building\api.py", line 620, in init self.versrsrc = versioninfo.load_version_info_from_text_file(self.versrsrc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\viktor.truderung\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyInstaller\utils\win32\versioninfo.py", line 575, in load_version_info_from_text_file raise ValueError("Failed to deserialize VSVersionInfo from text-based representation!") from e ValueError: Failed to deserialize VSVersionInfo from text-based representation!
Currently, I modify manually the version file produced by pyinstaller-versionfile
before giving it to Pyinstaller. For example:
...
StringStruct(u'ProductName', u'meow'),
PyInstaller 6.11 is happy with this:
OK, after reading up on it some more (including this helpful article and this section of the Microsoft docs), and experimenting myself, this is what I found.
TL;DR:
My proposal is:
VersionString
that can be set independently from Version
. Version
as default for VersionString
if not defined explicitlyVersion
for the FixedFileInfo
part that only allows integersVersionString
for the StringFileInfo
part (which is ultimately what is shown in the properties)Here the details:
filevers
and prodvers
in the FixedFileInfo
block are each two 32 bit integers. Therefore, in none of them a suffix is allowed.FileVersion
and ProductVersion
in the StringFileInfo
/StringTable
section can contain arbitrary strings. Therefore, in both of them the suffix would be OK. Even the Microsoft documentation has an example with RC2
suffix for both of them.mask
and flags
, which can be used to denote the "type" of build (e.g. DEBUG or PRERELEASE). At least in the first linked article, it seems to be a common practice to have a bit differing values for filevers
/prodvers
and their string counterparts FileVersion
/ProductVersion
.
While the FixedFileInfo
is intended to be consumed by programs, installers, or tools, the StringFileInfo
is what is used to display the information in the details section of the file properties.
And the difference between FileVersion
and ProductVersion
is, that the individual file could have a independently maintained version of the bundling product. For executables created by PyInstaller, I would say we can leave this out of scope.
So in summary, I would say the best way to specify the example of the opening post (24.10.0-dev) is:
FixedFileInfo
:
filevers
and prodvers
both to (24,10,0,0)
flags
for VS_FF_PRERELEASE
(see here for the corresponding bits) as well as the mask
StringFileInfo
:
FileVersion
and ProductVersion
as 24.10.0-dev
I'd like to customize the ProductVersion field. By default it could use the same value than Version (like it is implemented right now).
The reason is that I use tag suffixes (like 24.10.0-dev) and suffixes cannot appear in the Version field, but they work in ProductVersion.
Thanks :)