]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
ff88a05c | 2 | # coding: utf-8 |
3 | ||
e38df8f9 | 4 | from __future__ import unicode_literals |
5 | import sys | |
b3943b2f | 6 | # import os |
ff88a05c | 7 | import platform |
e38df8f9 | 8 | |
e36d50c5 | 9 | from PyInstaller.utils.hooks import collect_submodules |
e38df8f9 | 10 | from PyInstaller.utils.win32.versioninfo import ( |
11 | VarStruct, VarFileInfo, StringStruct, StringTable, | |
12 | StringFileInfo, FixedFileInfo, VSVersionInfo, SetVersion, | |
13 | ) | |
14 | import PyInstaller.__main__ | |
15 | ||
ff88a05c | 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 '' | |
e38df8f9 | 20 | |
cc1dfc93 | 21 | FILE_DESCRIPTION = 'yt-dlp%s' % (' (32 Bit)' if _x86 else '') |
e38df8f9 | 22 | |
b3943b2f | 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) | |
e38df8f9 | 26 | |
7a5c1cfe | 27 | exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec')) |
e38df8f9 | 28 | VERSION = locals()['__version__'] |
29 | ||
3dd264bf | 30 | VERSION_LIST = VERSION.split('.') |
e38df8f9 | 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( | |
ff88a05c | 50 | '040904B0', [ |
7a5c1cfe P |
51 | StringStruct('Comments', 'yt-dlp%s Command Line Interface.' % _x86), |
52 | StringStruct('CompanyName', 'https://github.com/yt-dlp'), | |
ff88a05c | 53 | StringStruct('FileDescription', FILE_DESCRIPTION), |
54 | StringStruct('FileVersion', VERSION), | |
7a5c1cfe | 55 | StringStruct('InternalName', 'yt-dlp%s' % _x86), |
e38df8f9 | 56 | StringStruct( |
ff88a05c | 57 | 'LegalCopyright', |
7a5c1cfe | 58 | 'pukkandan.ytdlp@gmail.com | UNLICENSE', |
e38df8f9 | 59 | ), |
7a5c1cfe P |
60 | StringStruct('OriginalFilename', 'yt-dlp%s.exe' % _x86), |
61 | StringStruct('ProductName', 'yt-dlp%s' % _x86), | |
56ce9eb8 NA |
62 | StringStruct( |
63 | 'ProductVersion', | |
64 | '%s%s on Python %s' % (VERSION, _x86, platform.python_version())), | |
e38df8f9 | 65 | ])]), |
ff88a05c | 66 | VarFileInfo([VarStruct('Translation', [0, 1200])]) |
e38df8f9 | 67 | ] |
68 | ) | |
69 | ||
e36d50c5 | 70 | dependancies = ['Crypto', 'mutagen'] + collect_submodules('websockets') |
71 | excluded_modules = ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc'] | |
72 | ||
e38df8f9 | 73 | PyInstaller.__main__.run([ |
7a5c1cfe | 74 | '--name=yt-dlp%s' % _x86, |
e38df8f9 | 75 | '--onefile', |
1aebc0f7 | 76 | '--icon=devscripts/logo.ico', |
e36d50c5 | 77 | *[f'--exclude-module={module}' for module in excluded_modules], |
78 | *[f'--hidden-import={module}' for module in dependancies], | |
46261325 | 79 | '--upx-exclude=vcruntime140.dll', |
7a5c1cfe | 80 | 'yt_dlp/__main__.py', |
e38df8f9 | 81 | ]) |
7a5c1cfe | 82 | SetVersion('dist/yt-dlp%s.exe' % _x86, VERSION_FILE) |