]> jfr.im git - yt-dlp.git/blob - pyinst.py
Add logo and banner
[yt-dlp.git] / pyinst.py
1 #!/usr/bin/env python3
2 # coding: utf-8
3
4 from __future__ import unicode_literals
5 import sys
6 # import os
7 import platform
8
9 from PyInstaller.utils.hooks import collect_submodules
10 from PyInstaller.utils.win32.versioninfo import (
11 VarStruct, VarFileInfo, StringStruct, StringTable,
12 StringFileInfo, FixedFileInfo, VSVersionInfo, SetVersion,
13 )
14 import PyInstaller.__main__
15
16 arch = sys.argv[1] if len(sys.argv) > 1 else platform.architecture()[0][:2]
17 assert arch in ('32', '64')
18 print('Building %sbit version' % arch)
19 _x86 = '_x86' if arch == '32' else ''
20
21 FILE_DESCRIPTION = 'yt-dlp%s' % (' (32 Bit)' if _x86 else '')
22
23 # root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
24 # print('Changing working directory to %s' % root_dir)
25 # os.chdir(root_dir)
26
27 exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
28 VERSION = locals()['__version__']
29
30 VERSION_LIST = VERSION.split('.')
31 VERSION_LIST = list(map(int, VERSION_LIST)) + [0] * (4 - len(VERSION_LIST))
32
33 print('Version: %s%s' % (VERSION, _x86))
34 print('Remember to update the version using devscipts\\update-version.py')
35
36 VERSION_FILE = VSVersionInfo(
37 ffi=FixedFileInfo(
38 filevers=VERSION_LIST,
39 prodvers=VERSION_LIST,
40 mask=0x3F,
41 flags=0x0,
42 OS=0x4,
43 fileType=0x1,
44 subtype=0x0,
45 date=(0, 0),
46 ),
47 kids=[
48 StringFileInfo([
49 StringTable(
50 '040904B0', [
51 StringStruct('Comments', 'yt-dlp%s Command Line Interface.' % _x86),
52 StringStruct('CompanyName', 'https://github.com/yt-dlp'),
53 StringStruct('FileDescription', FILE_DESCRIPTION),
54 StringStruct('FileVersion', VERSION),
55 StringStruct('InternalName', 'yt-dlp%s' % _x86),
56 StringStruct(
57 'LegalCopyright',
58 'pukkandan.ytdlp@gmail.com | UNLICENSE',
59 ),
60 StringStruct('OriginalFilename', 'yt-dlp%s.exe' % _x86),
61 StringStruct('ProductName', 'yt-dlp%s' % _x86),
62 StringStruct(
63 'ProductVersion',
64 '%s%s on Python %s' % (VERSION, _x86, platform.python_version())),
65 ])]),
66 VarFileInfo([VarStruct('Translation', [0, 1200])])
67 ]
68 )
69
70 dependancies = ['Crypto', 'mutagen'] + collect_submodules('websockets')
71 excluded_modules = ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc']
72
73 PyInstaller.__main__.run([
74 '--name=yt-dlp%s' % _x86,
75 '--onefile',
76 '--icon=devscripts/logo.ico',
77 *[f'--exclude-module={module}' for module in excluded_modules],
78 *[f'--hidden-import={module}' for module in dependancies],
79 '--upx-exclude=vcruntime140.dll',
80 'yt_dlp/__main__.py',
81 ])
82 SetVersion('dist/yt-dlp%s.exe' % _x86, VERSION_FILE)