DudeNr33 / pyinstaller-versionfile

Create a windows versionfile from a simple YAML file that can be used by PyInstaller.
MIT License
43 stars 5 forks source link

Add support to customize ProductVersion #26

Open pemessier opened 2 weeks ago

pemessier commented 2 weeks ago

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 :)

truderung commented 1 week 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.

DudeNr33 commented 1 week ago

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.

truderung commented 1 week ago

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!

pemessier commented 1 week ago

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: image

DudeNr33 commented 1 week ago

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:

Here the details:

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: