]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/update.py
[build, devscripts] Add devscript to set a build variant
[yt-dlp.git] / yt_dlp / update.py
index 92c07acc1401738d6f91c327a729874d5a0c399d..a04518c9b643fda11da4db0f68078b116ff2203c 100644 (file)
@@ -18,7 +18,7 @@
     traverse_obj,
     version_tuple,
 )
-from .version import __version__
+from .version import UPDATE_HINT, VARIANT, __version__
 
 REPOSITORY = 'yt-dlp/yt-dlp'
 API_URL = f'https://api.github.com/repos/{REPOSITORY}/releases'
@@ -47,7 +47,7 @@ def _get_variant_and_executable_path():
 
 
 def detect_variant():
-    return _get_variant_and_executable_path()[0]
+    return VARIANT or _get_variant_and_executable_path()[0]
 
 
 _FILE_SUFFIXES = {
@@ -64,13 +64,16 @@ def detect_variant():
     **{variant: f'Auto-update is not supported for unpackaged {name} executable; Re-download the latest release'
        for variant, name in {'win32_dir': 'Windows', 'darwin_dir': 'MacOS', 'linux_dir': 'Linux'}.items()},
     'source': 'You cannot update when running from source code; Use git to pull the latest changes',
-    'unknown': 'It looks like you installed yt-dlp with a package manager, pip or setup.py; Use that to update',
-    'other': 'It looks like you are using an unofficial build of yt-dlp; Build the executable again',
+    'unknown': 'You installed yt-dlp with a package manager or setup.py; Use that to update',
+    'other': 'You are using an unofficial build of yt-dlp; Build the executable again',
 }
 
 
 def is_non_updateable():
-    return _NON_UPDATEABLE_REASONS.get(detect_variant(), _NON_UPDATEABLE_REASONS['other'])
+    if UPDATE_HINT:
+        return UPDATE_HINT
+    return _NON_UPDATEABLE_REASONS.get(
+        detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])
 
 
 def _sha256_file(path):