From dec248adeccb973f5f891a319c757302f3b69eee Mon Sep 17 00:00:00 2001 From: Brannon King Date: Wed, 4 Mar 2020 17:08:47 -0700 Subject: [PATCH] repair env modified by pyinstaller see https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#ld-library-path-libpath-considerations --- lbry/file_analysis.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lbry/file_analysis.py b/lbry/file_analysis.py index d0e99c47c..3b9a25878 100644 --- a/lbry/file_analysis.py +++ b/lbry/file_analysis.py @@ -15,12 +15,20 @@ DISABLED = platform.system() == "Windows" class VideoFileAnalyzer: + def _replace_or_pop_env(self, variable): + if variable + '_ORIG' in self._env_copy: + self._env_copy[variable] = self._env_copy[variable + '_ORIG'] + else: + self._env_copy.pop(variable, None) + def __init__(self, conf: TranscodeConfig): self._conf = conf self._available_encoders = "" self._ffmpeg_installed = False self._which = None self._checked_ffmpeg = False + self._env_copy = dict(os.environ) + self._replace_or_pop_env('LD_LIBRARY_PATH') async def _execute(self, command, arguments): if DISABLED: @@ -28,7 +36,7 @@ class VideoFileAnalyzer: args = shlex.split(arguments) process = await asyncio.create_subprocess_exec( os.path.join(self._conf.ffmpeg_folder, command), *args, - stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE + stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=self._env_copy ) stdout, stderr = await process.communicate() # returns when the streams are closed return stdout.decode(errors='replace') + stderr.decode(errors='replace'), process.returncode