diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-02-09 01:12:08 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-02-09 01:46:56 +0530 |
commit | acb1042a9ffa8769fe691beac1011d6da1fcf321 (patch) | |
tree | d3ff03d3a3c04dcda0316537f87e08e060b7b2db /yt_dlp | |
parent | f40e32fb1ac67be5bdbc8e32a3c235abfc4be260 (diff) | |
download | hypervideo-pre-acb1042a9ffa8769fe691beac1011d6da1fcf321.tar.lz hypervideo-pre-acb1042a9ffa8769fe691beac1011d6da1fcf321.tar.xz hypervideo-pre-acb1042a9ffa8769fe691beac1011d6da1fcf321.zip |
[devscripts] Provide pyinstaller hooks
Closes #6185
Diffstat (limited to 'yt_dlp')
-rw-r--r-- | yt_dlp/__pyinstaller/__init__.py | 5 | ||||
-rw-r--r-- | yt_dlp/__pyinstaller/hook-yt_dlp.py | 29 | ||||
-rw-r--r-- | yt_dlp/compat/__init__.py | 6 |
3 files changed, 34 insertions, 6 deletions
diff --git a/yt_dlp/__pyinstaller/__init__.py b/yt_dlp/__pyinstaller/__init__.py new file mode 100644 index 000000000..1c52aadf4 --- /dev/null +++ b/yt_dlp/__pyinstaller/__init__.py @@ -0,0 +1,5 @@ +import os + + +def get_hook_dirs(): + return [os.path.dirname(__file__)] diff --git a/yt_dlp/__pyinstaller/hook-yt_dlp.py b/yt_dlp/__pyinstaller/hook-yt_dlp.py new file mode 100644 index 000000000..66d1b6369 --- /dev/null +++ b/yt_dlp/__pyinstaller/hook-yt_dlp.py @@ -0,0 +1,29 @@ +import sys + +from PyInstaller.utils.hooks import collect_submodules + + +def _pycryptodome_module(): + try: + import Cryptodome # noqa: F401 + except ImportError: + try: + import Crypto # noqa: F401 + print('WARNING: Using Crypto since Cryptodome is not available. ' + 'Install with: pip install pycryptodomex', file=sys.stderr) + return 'Crypto' + except ImportError: + pass + return 'Cryptodome' + + +def _hidden_imports(): + yield 'yt_dlp.compat._legacy' + for m in [_pycryptodome_module(), 'websockets']: + yield from collect_submodules(m) + # These are auto-detected, but explicitly add them just in case + yield from ('mutagen', 'brotli', 'certifi') + + +hiddenimports = list(_hidden_imports()) +excludedimports = ['youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins', 'devscripts'] diff --git a/yt_dlp/compat/__init__.py b/yt_dlp/compat/__init__.py index 5cc78ebc2..c6c02541c 100644 --- a/yt_dlp/compat/__init__.py +++ b/yt_dlp/compat/__init__.py @@ -70,9 +70,3 @@ if compat_os_name in ('nt', 'ce'): return userhome + path[i:] else: compat_expanduser = os.path.expanduser - - -# NB: Add modules that are imported dynamically here so that PyInstaller can find them -# See https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/438 -if False: - from . import _legacy # noqa: F401 |