diff options
author | Jesús <heckyel@hyperbola.info> | 2022-06-27 01:25:17 +0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-06-27 01:25:17 +0800 |
commit | 16e8548f6a720a78679e417a20a300db2036bf6c (patch) | |
tree | b1247bca3417ce882e4a4d80213f41c20113c1a4 /pyinst.py | |
parent | 4bbf329feb5a820ac21269fa426c95ca14d7af25 (diff) | |
parent | e08f72e6759fb6b1102521f0bdb9457038ef7c06 (diff) | |
download | hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.tar.lz hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.tar.xz hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.zip |
updated from upstream | 27/06/2022 at 01:25
Diffstat (limited to 'pyinst.py')
-rw-r--r-- | pyinst.py | 53 |
1 files changed, 30 insertions, 23 deletions
@@ -1,28 +1,12 @@ #!/usr/bin/env python3 + import os import platform import sys from PyInstaller.__main__ import run as run_pyinstaller -OS_NAME = platform.system() -if OS_NAME == 'Windows': - from PyInstaller.utils.win32.versioninfo import ( - FixedFileInfo, - SetVersion, - StringFileInfo, - StringStruct, - StringTable, - VarFileInfo, - VarStruct, - VSVersionInfo, - ) -elif OS_NAME == 'Darwin': - pass -else: - raise Exception(f'{OS_NAME} is not supported') - -ARCH = platform.architecture()[0][:2] +OS_NAME, ARCH = sys.platform, platform.architecture()[0][:2] def main(): @@ -33,10 +17,7 @@ def main(): if not onedir and '-F' not in opts and '--onefile' not in opts: opts.append('--onefile') - name = 'yt-dlp%s' % ('_macos' if OS_NAME == 'Darwin' else '_x86' if ARCH == '32' else '') - final_file = ''.join(( - 'dist/', f'{name}/' if onedir else '', name, '.exe' if OS_NAME == 'Windows' else '')) - + name, final_file = exe(onedir) print(f'Building yt-dlp v{version} {ARCH}bit for {OS_NAME} with options {opts}') print('Remember to update the version using "devscripts/update-version.py"') if not os.path.isfile('yt_dlp/extractor/lazy_extractors.py'): @@ -79,6 +60,21 @@ def read_version(fname): return locals()['__version__'] +def exe(onedir): + """@returns (name, path)""" + name = '_'.join(filter(None, ( + 'yt-dlp', + {'win32': '', 'darwin': 'macos'}.get(OS_NAME, OS_NAME), + ARCH == '32' and 'x86' + ))) + return name, ''.join(filter(None, ( + 'dist/', + onedir and f'{name}/', + name, + OS_NAME == 'win32' and '.exe' + ))) + + def version_to_list(version): version_list = version.split('.') return list(map(int, version_list)) + [0] * (4 - len(version_list)) @@ -109,11 +105,22 @@ def pycryptodome_module(): def set_version_info(exe, version): - if OS_NAME == 'Windows': + if OS_NAME == 'win32': windows_set_version(exe, version) def windows_set_version(exe, version): + from PyInstaller.utils.win32.versioninfo import ( + FixedFileInfo, + SetVersion, + StringFileInfo, + StringStruct, + StringTable, + VarFileInfo, + VarStruct, + VSVersionInfo, + ) + version_list = version_to_list(version) suffix = '_x86' if ARCH == '32' else '' SetVersion(exe, VSVersionInfo( |