]> jfr.im git - yt-dlp.git/blame_incremental - pyinst.py
[youtube] Add `mobile_web` client (#557)
[yt-dlp.git] / pyinst.py
... / ...
CommitLineData
1#!/usr/bin/env python3
2# coding: utf-8
3
4from __future__ import unicode_literals
5import sys
6# import os
7import platform
8
9from PyInstaller.utils.hooks import collect_submodules
10from PyInstaller.utils.win32.versioninfo import (
11 VarStruct, VarFileInfo, StringStruct, StringTable,
12 StringFileInfo, FixedFileInfo, VSVersionInfo, SetVersion,
13)
14import PyInstaller.__main__
15
16arch = sys.argv[1] if len(sys.argv) > 1 else platform.architecture()[0][:2]
17assert arch in ('32', '64')
18print('Building %sbit version' % arch)
19_x86 = '_x86' if arch == '32' else ''
20
21FILE_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
27exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
28VERSION = locals()['__version__']
29
30VERSION_LIST = VERSION.split('.')
31VERSION_LIST = list(map(int, VERSION_LIST)) + [0] * (4 - len(VERSION_LIST))
32
33print('Version: %s%s' % (VERSION, _x86))
34print('Remember to update the version using devscipts\\update-version.py')
35
36VERSION_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
70dependancies = ['Crypto', 'mutagen'] + collect_submodules('websockets')
71excluded_modules = ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc']
72
73PyInstaller.__main__.run([
74 '--name=yt-dlp%s' % _x86,
75 '--onefile',
76 '--icon=devscripts/cloud.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])
82SetVersion('dist/yt-dlp%s.exe' % _x86, VERSION_FILE)