diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-10-04 02:25:13 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-10-04 03:08:27 +0530 |
commit | 5d535b4a559ff114866368bfb3cde38b54f9462b (patch) | |
tree | 386dd3e38534b57f386eba4d8aa109c505c867d5 /yt_dlp/update.py | |
parent | a1c3967307053767d8c44a5814c88610fe6c4860 (diff) | |
download | hypervideo-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 'yt_dlp/update.py')
-rw-r--r-- | yt_dlp/update.py | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/yt_dlp/update.py b/yt_dlp/update.py index 8160dab37..4fbe7bd7e 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -32,10 +32,12 @@ def rsa_verify(message, signature, key): def detect_variant(): - if hasattr(sys, 'frozen') and getattr(sys, '_MEIPASS', None): - if sys._MEIPASS == os.path.dirname(sys.executable): - return 'dir' - return 'exe' + if hasattr(sys, 'frozen'): + if getattr(sys, '_MEIPASS', None): + if sys._MEIPASS == os.path.dirname(sys.executable): + return 'dir' + return 'exe' + return 'py2exe' elif isinstance(globals().get('__loader__'), zipimporter): return 'zip' elif os.path.basename(sys.argv[0]) == '__main__.py': @@ -43,6 +45,20 @@ def detect_variant(): return 'unknown' +_NON_UPDATEABLE_REASONS = { + 'exe': None, + 'zip': None, + 'dir': 'Auto-update is not supported for unpackaged windows executable. Re-download the latest release', + 'py2exe': 'There is no official release for py2exe executable. Build it again with the latest source code', + 'source': 'You cannot update when running from source code', + 'unknown': 'It looks like you installed yt-dlp with a package manager, pip, setup.py or a tarball. Use that to update', +} + + +def is_non_updateable(): + return _NON_UPDATEABLE_REASONS.get(detect_variant(), _NON_UPDATEABLE_REASONS['unknown']) + + def update_self(to_screen, verbose, opener): ''' Exists for backward compatibility. Use run_update(ydl) instead ''' @@ -114,14 +130,7 @@ def run_update(ydl): ydl.to_screen(f'yt-dlp is up to date ({__version__})') return - ERRORS = { - 'exe': None, - 'zip': None, - 'dir': 'Auto-update is not supported for unpackaged windows executable. Re-download the latest release', - 'source': 'You cannot update when running from source code', - 'unknown': 'It looks like you installed yt-dlp with a package manager, pip, setup.py or a tarball. Use that to update', - } - err = ERRORS.get(detect_variant(), ERRORS['unknown']) + err = is_non_updateable() if err: ydl.to_screen(f'Latest version: {version_id}, Current version: {__version__}') return report_error(err, expected=True) |