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