aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLesmiscore <nao20010128@gmail.com>2022-08-31 01:24:14 +0900
committerGitHub <noreply@github.com>2022-08-31 01:24:14 +0900
commit82ea226c61880c9118cce32681e54be24839519a (patch)
treeab9b85f6afbba809bfaea63e584eec4df058773d
parentda4db748fa813a8de684d5ab699b8f561b982e35 (diff)
downloadhypervideo-pre-82ea226c61880c9118cce32681e54be24839519a.tar.lz
hypervideo-pre-82ea226c61880c9118cce32681e54be24839519a.tar.xz
hypervideo-pre-82ea226c61880c9118cce32681e54be24839519a.zip
Restore LD_LIBRARY_PATH when using PyInstaller (#4666)
Authored by: Lesmiscore
-rw-r--r--yt_dlp/utils.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index da2d042cb..00f2fbf42 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -840,12 +840,35 @@ class Popen(subprocess.Popen):
else:
_startupinfo = None
- def __init__(self, *args, text=False, **kwargs):
+ @staticmethod
+ def _fix_pyinstaller_ld_path(env):
+ """Restore LD_LIBRARY_PATH when using PyInstaller
+ Ref: https://github.com/pyinstaller/pyinstaller/blob/develop/doc/runtime-information.rst#ld_library_path--libpath-considerations
+ https://github.com/yt-dlp/yt-dlp/issues/4573
+ """
+ if not hasattr(sys, '_MEIPASS'):
+ return
+
+ def _fix(key):
+ orig = env.get(f'{key}_ORIG')
+ if orig is None:
+ env.pop(key, None)
+ else:
+ env[key] = orig
+
+ _fix('LD_LIBRARY_PATH') # Linux
+ _fix('DYLD_LIBRARY_PATH') # macOS
+
+ def __init__(self, *args, env=None, text=False, **kwargs):
+ if env is None:
+ env = os.environ.copy()
+ self._fix_pyinstaller_ld_path(env)
+
if text is True:
kwargs['universal_newlines'] = True # For 3.6 compatibility
kwargs.setdefault('encoding', 'utf-8')
kwargs.setdefault('errors', 'replace')
- super().__init__(*args, **kwargs, startupinfo=self._startupinfo)
+ super().__init__(*args, env=env, **kwargs, startupinfo=self._startupinfo)
def communicate_or_kill(self, *args, **kwargs):
try: