aboutsummaryrefslogtreecommitdiffstats
path: root/pyinst.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-10-04 02:25:13 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-10-04 03:08:27 +0530
commit5d535b4a559ff114866368bfb3cde38b54f9462b (patch)
tree386dd3e38534b57f386eba4d8aa109c505c867d5 /pyinst.py
parenta1c3967307053767d8c44a5814c88610fe6c4860 (diff)
downloadhypervideo-pre-5d535b4a559ff114866368bfb3cde38b54f9462b.tar.lz
hypervideo-pre-5d535b4a559ff114866368bfb3cde38b54f9462b.tar.xz
hypervideo-pre-5d535b4a559ff114866368bfb3cde38b54f9462b.zip
[build] Allow building with py2exe (and misc fixes)
py2exe config is copied from youtube-dl Closes #1160
Diffstat (limited to 'pyinst.py')
-rw-r--r--pyinst.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/pyinst.py b/pyinst.py
index d65243f88..7e040647c 100644
--- a/pyinst.py
+++ b/pyinst.py
@@ -13,11 +13,18 @@ from PyInstaller.utils.win32.versioninfo import (
)
import PyInstaller.__main__
-arch = sys.argv[1] if len(sys.argv) > 1 else platform.architecture()[0][:2]
+arch = platform.architecture()[0][:2]
assert arch in ('32', '64')
_x86 = '_x86' if arch == '32' else ''
-opts = sys.argv[2:] or ['--onefile']
+# Compatability with older arguments
+opts = sys.argv[1:]
+if opts[0:1] in (['32'], ['64']):
+ if arch != opts[0]:
+ raise Exception(f'{opts[0]}bit executable cannot be built on a {arch}bit system')
+ opts = opts[1:]
+opts = opts or ['--onefile']
+
print(f'Building {arch}bit version with options {opts}')
FILE_DESCRIPTION = 'yt-dlp%s' % (' (32 Bit)' if _x86 else '')
@@ -82,4 +89,4 @@ PyInstaller.__main__.run([
*opts,
'yt_dlp/__main__.py',
])
-SetVersion('dist/yt-dlp%s.exe' % _x86, VERSION_FILE)
+SetVersion('dist/%syt-dlp%s.exe' % ('yt-dlp/' if '--onedir' in opts else '', _x86), VERSION_FILE)