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