]>
jfr.im git - yt-dlp.git/blob - pyinst.py
4 from __future__
import unicode_literals
8 from PyInstaller
.utils
.hooks
import collect_submodules
9 from PyInstaller
.utils
.win32
.versioninfo
import (
10 VarStruct
, VarFileInfo
, StringStruct
, StringTable
,
11 StringFileInfo
, FixedFileInfo
, VSVersionInfo
, SetVersion
,
13 import PyInstaller
.__main
__
15 arch
= platform
.architecture()[0][:2]
16 assert arch
in ('32', '64')
17 _x86
= '_x86' if arch
== '32' else ''
19 # Compatability with older arguments
21 if opts
[0:1] in (['32'], ['64']):
23 raise Exception(f
'{opts[0]}bit executable cannot be built on a {arch}bit system')
25 opts
= opts
or ['--onefile']
27 print(f
'Building {arch}bit version with options {opts}')
29 FILE_DESCRIPTION
= 'yt-dlp%s' % (' (32 Bit)' if _x86
else '')
31 exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
32 VERSION
= locals()['__version__']
34 VERSION_LIST
= VERSION
.split('.')
35 VERSION_LIST
= list(map(int, VERSION_LIST
)) + [0] * (4 - len(VERSION_LIST
))
37 print('Version: %s%s' % (VERSION
, _x86
))
38 print('Remember to update the version using devscipts\\update-version.py')
40 VERSION_FILE
= VSVersionInfo(
42 filevers
=VERSION_LIST
,
43 prodvers
=VERSION_LIST
,
55 StringStruct('Comments', 'yt-dlp%s Command Line Interface.' % _x86
),
56 StringStruct('CompanyName', 'https://github.com/yt-dlp'),
57 StringStruct('FileDescription', FILE_DESCRIPTION
),
58 StringStruct('FileVersion', VERSION
),
59 StringStruct('InternalName', 'yt-dlp%s' % _x86
),
62 'pukkandan.ytdlp@gmail.com | UNLICENSE',
64 StringStruct('OriginalFilename', 'yt-dlp%s.exe' % _x86
),
65 StringStruct('ProductName', 'yt-dlp%s' % _x86
),
68 '%s%s on Python %s' % (VERSION
, _x86
, platform
.python_version())),
70 VarFileInfo([VarStruct('Translation', [0, 1200])])
75 def pycryptodome_module():
77 import Cryptodome
# noqa: F401
80 import Crypto
# noqa: F401
81 print('WARNING: Using Crypto since Cryptodome is not available. '
82 'Install with: pip install pycryptodomex', file=sys
.stderr
)
89 dependancies
= [pycryptodome_module(), 'mutagen'] + collect_submodules('websockets')
90 excluded_modules
= ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc']
92 PyInstaller
.__main
__.run([
93 '--name=yt-dlp%s' % _x86
,
94 '--icon=devscripts/logo.ico',
95 *[f
'--exclude-module={module}' for module
in excluded_modules
],
96 *[f
'--hidden-import={module}' for module
in dependancies
],
97 '--upx-exclude=vcruntime140.dll',
100 'yt_dlp/__main__.py',
102 SetVersion('dist/%syt-dlp%s.exe' % ('yt-dlp/' if '--onedir' in opts
else '', _x86
), VERSION_FILE
)