Pyinstaller: add VERSIONINFO resource to Windows executables.

This commit is contained in:
bitraid 2018-04-20 17:48:51 +03:00
parent 178eeaed0d
commit 8c16d81d89
4 changed files with 119 additions and 1 deletions

45
file_version_info.txt Normal file
View File

@ -0,0 +1,45 @@
# 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=(1, 2, 1, 0),
prodvers=(1, 2, 1, 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=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904B0',
[StringStruct(u'Comments', u'A keyboard-focused browser with a minimal GUI.'),
StringStruct(u'CompanyName', u'qutebrowser.org'),
StringStruct(u'FileDescription', u'qutebrowser'),
StringStruct(u'FileVersion', u'1.2.1'),
StringStruct(u'InternalName', u'qutebrowser'),
StringStruct(u'LegalCopyright', u'© 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>'),
StringStruct(u'LegalTrademarks', u'qutebrowser is free software under the GNU General Public License'),
StringStruct(u'OriginalFilename', u'qutebrowser.exe'),
StringStruct(u'ProductName', u'qutebrowser'),
StringStruct(u'ProductVersion', u'1.2.1')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)

View File

@ -59,7 +59,8 @@ exe = EXE(pyz,
debug=False, debug=False,
strip=False, strip=False,
upx=False, upx=False,
console=False ) console=False,
version='file_version_info.txt' )
coll = COLLECT(exe, coll = COLLECT(exe,
a.binaries, a.binaries,
a.zipfiles, a.zipfiles,

View File

@ -40,6 +40,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
import qutebrowser import qutebrowser
from scripts import utils from scripts import utils
# from scripts.dev import update_3rdparty # from scripts.dev import update_3rdparty
from scripts.dev import gen_versioninfo
def call_script(name, *args, python=sys.executable): def call_script(name, *args, python=sys.executable):
@ -232,6 +233,9 @@ def build_windows():
artifacts = [] artifacts = []
utils.print_title("Updating VersionInfo file")
gen_versioninfo
utils.print_title("Running pyinstaller 32bit") utils.print_title("Running pyinstaller 32bit")
_maybe_remove(out_32) _maybe_remove(out_32)
call_tox('pyinstaller', '-r', python=python_x86) call_tox('pyinstaller', '-r', python=python_x86)

View File

@ -0,0 +1,68 @@
#!/usr/bin/env python3
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Generate file_version_info.txt for Pyinstaller use with Windows builds."""
import os
import os.path
import sys
from PyInstaller.utils.win32 import versioninfo
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir))
import qutebrowser
out_filename = 'file_version_info.txt'
FileVersion = qutebrowser.__version_info__ + (0,)
ProductVersion = qutebrowser.__version_info__ + (0,)
CommentText = "A keyboard-focused browser with a minimal GUI."
CopyrightText = "© 2014-2018 Florian Bruhin (The Compiler) \
<mail@qutebrowser.org>"
TrademarkText = "qutebrowser is free software under the GNU General Public \
License"
FixedFileInfo = versioninfo.FixedFileInfo(FileVersion, ProductVersion)
StringFileInfo = [versioninfo.StringFileInfo(
[versioninfo.StringTable('040904B0',
[versioninfo.StringStruct('Comments',f'{CommentText}'),
versioninfo.StringStruct('CompanyName',"qutebrowser.org"),
versioninfo.StringStruct('FileDescription',"qutebrowser"),
versioninfo.StringStruct('FileVersion',f'{qutebrowser.__version__}'),
versioninfo.StringStruct('InternalName',"qutebrowser"),
versioninfo.StringStruct('LegalCopyright',f'{CopyrightText}'),
versioninfo.StringStruct('LegalTrademarks',f'{TrademarkText}'),
versioninfo.StringStruct('OriginalFilename',"qutebrowser.exe"),
versioninfo.StringStruct('ProductName',"qutebrowser"),
versioninfo.StringStruct('ProductVersion',f'{qutebrowser.__version__}')])]),
versioninfo.VarFileInfo([versioninfo.VarStruct('Translation',
[1033, 1200])])]
VSVersionInfo = versioninfo.VSVersionInfo(FixedFileInfo, StringFileInfo)
with open(out_filename, 'w', encoding='utf-8') as f:
f.write(f'{VSVersionInfo}')
f.close()