def windows_set_version(exe, version): version_list = version_to_list(version) suffix = '_x86' if ARCH == '32' else '' SetVersion(exe, VSVersionInfo( ffi=FixedFileInfo( filevers=version_list, prodvers=version_list, mask=0x3F, flags=0x0, OS=0x4, fileType=0x1, subtype=0x0, date=(0, 0), ), kids=[ StringFileInfo([StringTable('040904B0', [ StringStruct('Comments', 'yt-dlp%s Command Line Interface.' % suffix), StringStruct('CompanyName', 'https://github.com/yt-dlp'), StringStruct('FileDescription', 'yt-dlp%s' % (' (32 Bit)' if ARCH == '32' else '')), StringStruct('FileVersion', version), StringStruct('InternalName', f'yt-dlp{suffix}'), StringStruct('LegalCopyright', '[email protected] | UNLICENSE'), StringStruct('OriginalFilename', f'yt-dlp{suffix}.exe'), StringStruct('ProductName', f'yt-dlp{suffix}'), StringStruct( 'ProductVersion', f'{version}{suffix} on Python {platform.python_version()}'), ])]), VarFileInfo([VarStruct('Translation', [0, 1200])]) ] ))
def test_versioninfo(tmp_path): from PyInstaller.utils.win32.versioninfo import VSVersionInfo, \ FixedFileInfo, StringFileInfo, StringTable, StringStruct, \ VarFileInfo, VarStruct vsinfo = VSVersionInfo( ffi=FixedFileInfo(filevers=(1, 2, 3, 4), prodvers=(5, 6, 7, 8), mask=0x3f, flags=0x1, OS=0x40004, fileType=0x42, subtype=0x42, date=(0, 0)), kids=[ StringFileInfo([ StringTable( '040904b0', [StringStruct('FileDescription', 'versioninfo test')]) ]), VarFileInfo([VarStruct('Translation', [1033, 1200])]) ]) file = str(tmp_path / 'versioninfo') save_py_data_struct(file, vsinfo) assert vsinfo == load_py_data_struct(file)
StringStruct('CompanyName', 'https://github.com/yt-dlp'), StringStruct('FileDescription', FILE_DESCRIPTION), StringStruct('FileVersion', VERSION), StringStruct('InternalName', 'yt-dlp%s' % _x86), StringStruct( 'LegalCopyright', '[email protected] | UNLICENSE', ), StringStruct('OriginalFilename', 'yt-dlp%s.exe' % _x86), StringStruct('ProductName', 'yt-dlp%s' % _x86), StringStruct( 'ProductVersion', '%s%s on Python %s' % (VERSION, _x86, platform.python_version())), ]) ]), VarFileInfo([VarStruct('Translation', [0, 1200])]) ]) dependancies = ['Crypto', 'mutagen'] + collect_submodules('websockets') excluded_modules = ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc'] PyInstaller.__main__.run([ '--name=yt-dlp%s' % _x86, '--onefile', '--icon=devscripts/cloud.ico', *[f'--exclude-module={module}' for module in excluded_modules], *[f'--hidden-import={module}' for module in dependancies], '--upx-exclude=vcruntime140.dll', 'yt_dlp/__main__.py', ]) SetVersion('dist/yt-dlp%s.exe' % _x86, VERSION_FILE)
StringTable( "040904B0", [ StringStruct("Comments", "Youtube-dlc_x86 Command Line Interface."), StringStruct("CompanyName", "*****@*****.**"), StringStruct("FileDescription", FILE_DESCRIPTION), StringStruct("FileVersion", version), StringStruct("InternalName", "youtube-dlc_x86"), StringStruct( "LegalCopyright", "[email protected] | UNLICENSE", ), StringStruct("OriginalFilename", "youtube-dlc_x86.exe"), StringStruct("ProductName", "Youtube-dlc_x86"), StringStruct("ProductVersion", version + "_x86 | git.io/JUGsM"), ], ) ]), VarFileInfo([VarStruct("Translation", [0, 1200])]) ]) PyInstaller.__main__.run([ '--name=youtube-dlc_x86', '--onefile', '--icon=win/icon/cloud.ico', 'youtube_dlc/__main__.py', ]) SetVersion('dist/youtube-dlc_x86.exe', version_file)
class BuildPyinstallerBin(Command): description = "Build the executable" user_options = [] version_file = None if pyi_compat and pyi_compat.is_win: version_file = VSVersionInfo( ffi=FixedFileInfo( filevers=version2tuple(), prodvers=version2tuple(), mask=0x3F, flags=0x0, OS=0x4, fileType=0x1, subtype=0x0, date=(0, 0), ), kids=[ VarFileInfo([VarStruct("Translation", [0, 1200])]), StringFileInfo( [ StringTable( "000004b0", [ StringStruct("CompanyName", __maintainer_contact__), StringStruct("FileDescription", DESCRIPTION), StringStruct("FileVersion", version2str()), StringStruct("InternalName", "youtube-dl-gui.exe"), StringStruct( "LegalCopyright", __projecturl__ + "LICENSE", ), StringStruct("OriginalFilename", "youtube-dl-gui.exe"), StringStruct("ProductName", __appname__), StringStruct("ProductVersion", version2str()), ], ) ] ), ], ) def initialize_options(self): pass def finalize_options(self): pass def run(self, version=version_file): """Run pyinstaller""" if on_windows(): path_sep = ";" else: path_sep = ":" spawn( [ "pyinstaller", "-w", "-F", "--icon=UI/images/icon.ico", "--add-data=UI/images"+path_sep+"UI/images", "--name=youtube-dl-gui", "main.py", ], dry_run=self.dry_run) if version: time.sleep(3) SetVersion("./dist/youtube-dl-gui.exe", version)
class BuildPyinstallerBin(Command): description = "Build the executable" user_options = [] version_file = None if pyi_compat and pyi_compat.is_win: version_file = VSVersionInfo( ffi=FixedFileInfo( filevers=version2tuple(), prodvers=version2tuple(), mask=0x3F, flags=0x0, OS=0x4, fileType=0x1, subtype=0x0, date=(0, 0), ), kids=[ VarFileInfo([VarStruct("Translation", [0, 1200])]), StringFileInfo([ StringTable( "000004b0", [ StringStruct("CompanyName", "*****@*****.**"), StringStruct("FileDescription", DESCRIPTION), StringStruct("FileVersion", version2str()), StringStruct("InternalName", "picta-dl.exe"), StringStruct( "LegalCopyright", "https://github.com/oleksis/picta-dl/LICENSE", ), StringStruct("OriginalFilename", "picta-dl.exe"), StringStruct("ProductName", "Picta-DL"), StringStruct("ProductVersion", version2str()), ], ) ]), ], ) def initialize_options(self): pass def finalize_options(self): pass def run(self, version=version_file): spawn( [ "pyinstaller", "-c", "-F", "--icon=assets/picta-dl.ico", "--exclude-module=test", "--name=picta-dl", "picta_dl/__main__.py", ], dry_run=self.dry_run, ) if version: time.sleep(3) SetVersion("./dist/picta-dl.exe", version)