-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override file version for win32 #2772
Conversation
The pywin32 module, used by cx_Freeze in Windows allows only integer numbering in the file's VERSION. So, all other symbols must be replaced when file versioning used in Windows. This change allows "freeze" while versioning style may be kept.
More info. Just got an error when tried appveyor to build with pywin32 module installed in Python 3.6.8 (cx_Freeze suggested to install the pywin32 ^_^), so decided to change the source here. May become useful as first step to resolve the #2762 |
Interesting! This version-identifier change makes a lot of sense to me, it seems like a good solution to the problem of pywin32's versioning rules. However, if the inclusion of executable metadata is predicated on pywin32 being installed (which would seem to be the case, as the version string would've always been incompatible with Win32, yet it never came up before), then we may have a larger issue. The GitLab builders that build the official Windows packages for OpenShot are, I believe, using the Lines 81 to 87 in ba259c1
The problem? pywin32 isn't available there, and probably never will be, as it apparently uses M$-proprietary hooks. As one pyinstaller developer put it, "pywin32 is pretty horrible IMHO, using MSVC specific features for no other reason than to be unportable." So it's only ever going to be available in the Windows-native Python, not any of the open-source environments. There is pywin32-ctypes, which is available for all platforms including MinGW-64 ( |
But the version string still needs adaptation. Windows expects only 4 numbers as far as I understand. No matter what tool will be used (if ever will it). |
Oh, absolutely, 100% agreed. This change makes total sense regardless. It's a step in the right direction, at least. |
Looking through (Referring to def _AddVersionResource(self, exe):
try:
from win32verstamp import stamp
except:
print("*** WARNING *** unable to create version resource")
print("install pywin32 extensions first")
return
fileName = exe.targetName
versionInfo = VersionInfo(self.metadata.version,
comments = self.metadata.long_description,
description = self.metadata.description,
company = self.metadata.author,
product = self.metadata.name,
copyright = exe.copyright,
trademarks = exe.trademarks)
stamp(fileName, versionInfo) |
Custom Win32GUI from cx_Freeze (http://www.mingw.org/wiki/ms_resource_compiler) each time? |
Problem is that the file that becomes That's apparently the purpose of the On the Perl side there seem to be a few more options:
I can even use Win32::Exe to modify the data of an executable's existing version resources. For instance, this Perl program: #!/bin/perl -w
use strict qw(subs vars refs);
use Win32::Exe;
use Data::Dumper;
my $exe = Win32::Exe->new($ARGV[0]);
print("Loaded ".$exe->filename."\n");
print("Subsystem: ".$exe->get_subsystem."\n");
print("Cannot create resource section!\n") unless $exe->can_create_resource_section;
my $inforef = $exe->get_version_info;
#my $manifest = $exe->get_manifest if $exe->has_manifest;
my @iconnames = $exe->get_group_icon_names;
print("Iconnames: ".join(' ',@iconnames)."\n");
print Data::Dumper->Dump([$inforef], ["inforef"]);
$inforef->{'ProductName'} = 'OpenShot Installer';
$inforef->{'ProductVersion'} = '2.4.4.1';
$exe->set_version_info($inforef);
$exe->write;
$inforef = $exe->get_version_info;
print Data::Dumper->Dump([$inforef], ["inforef"]); When run on the OpenShot 2.4.4 installer generated by InnoSetup (saved as $ perl testres.pl /tmp/openshot-installer.exe
Loaded /tmp/openshot-installer.exe
Subsystem: windows
Cannot create resource section!
Iconnames: MAINICON
$inforef = {
'LegalCopyright' => 'Copyright (c) 2008-2016 OpenShot Studios, LLC ',
'FileVersion' => '2.4.4.0',
'ProductName' => 'OpenShot Video Editor ',
'FileDescription' => 'OpenShot Video Editor Setup ',
'ProductVersion' => '2.4.4.0',
'CompanyName' => 'OpenShot Studios, LLC ',
'Comments' => 'This installation was built with Inno Setup.'
};
$inforef = {
'FileVersion' => '2.4.4.0',
'CompanyName' => 'OpenShot Studios, LLC ',
'Comments' => 'This installation was built with Inno Setup.',
'FileDescription' => 'OpenShot Video Editor Setup ',
'ProductName' => 'OpenShot Installer',
'InternalName' => 'openshot-installer.exe',
'OriginalFilename' => 'openshot-installer.exe',
'LegalCopyright' => 'Copyright (c) 2008-2016 OpenShot Studios, LLC ',
'LegalTrademarks' => '',
'ProductVersion' => '2.4.4.1'
}; Success! (It even adds a few properties, like OriginalFilename, and sets them automatically.) But Win32::Exe has the same limitation as pywin32: it requires Windows APIs for some operations. That's evidenced by the $ perl testres.pl /tmp/launch.exe
Loaded /tmp/launch.exe
Subsystem: windows
Cannot create resource section!
Iconnames: #1
$inforef = undef;
$inforef = undef; So CLOSE... and yet still not quite there, when it comes to our specific needs. There are, I suppose, two possible solutions to this:
|
(To say nothing of the fact that |
On .rc change the Win32GUI.exe can be recompiled I think, it is small file. You don't like the method? |
It's more an issue of, cx_freeze doesn't like that method (seemingly). You're right, recompiling the launcher isn't really a big thing. But cx_freeze avoids doing that, preferring instead to Nevertheless, because it's not how cx_freeze approaches the problem, in order to compile a
And even if we do all that, then for anyone using a different version of cx_freeze, or if we ever decide to update our own version, the sources have to be synced up to ensure that we aren't potentially using an incompatible version of the launcher. The path of least resistance may just be to install verpatch, and have verpatch_command = '"C:\path\to\verpatch.exe" "{}" /va /high {} /pv {} /s product {} /s company {}
/s copyright {} {}'.format(os.path.join(exe_path, "launch.exe"), infoVersion, infoVersion,
info.PRODUCT_NAME, info.COMPANY_NAME, info.COPYRIGHT); |
Heh! In fact, it turns out verpatch launch.exe /va /high 2.4.4-dev1 /pv 2.4.4-dev1 /s company "OpenShot Studios, LLC"
/s copyright "Copyright (c) 2008-2019 OpenShot Studios, LLC" /s product "OpenShot Video Editor" |
Hm, we should also make sure to set the File Description field ( |
Probably, better to not set anything until application's major issues will be fixed. Because the number of Windows users is really huge. |
So, if we can successfully set the version (as is) using verpatch, I don't think this PR is needed anymore. But I still appreciate your for submitting this one, because it led us to a good solution I think (#2810)!! Thanks again... going to close it. |
@jonoomph You are going against Windows tools, this is not the best decision on Windows, IMHO. |
I don't claim to be any kind of Windows expert, but from what I've been able to learn, that's not the case. Windows may use those So, the impression I get is that this is fine. And I got that impression from Microsoft. Their own docs for the Windows Version Information resource include a String table that holds
Seems like we're fine, by my reading. |
i´m on windows can´t manipulate or recompile the software!!!... i´m loosing all my projects!!! |
The pywin32 module, when used by cx_Freeze in Windows doesn't allow not integer versioning of the files in the first 4 numbers.
This change allows "freeze" while versioning style may be kept.
It doesn't changes logging info of the OpenShot, only file description is affected.