mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-09 07:27:01 +00:00
Run mpv subprocess with a system PYTHONPATH env on macOS.
youtube-dl relies on system python to run on macOS, but system python cannot be executed in a subprocess created from the frozen python3 executable. This makes youtube-dl unusable from frozen versions of Syncplay on macOS. So, the environment of the mpv subprocess is modified with system PYTHONPATH, allowing the execution of /usr/bin/python (and hence, of youtube-dl) from within the subprocess in frozen executables. Fixes: #228
This commit is contained in:
parent
22eec119b1
commit
c07206c189
@ -1,4 +1,5 @@
|
||||
# coding:utf8
|
||||
import ast
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@ -10,7 +11,7 @@ import time
|
||||
from syncplay import constants, utils
|
||||
from syncplay.players.basePlayer import BasePlayer
|
||||
from syncplay.messages import getMessage
|
||||
from syncplay.utils import isWindows
|
||||
from syncplay.utils import isMacOS, isWindows
|
||||
|
||||
|
||||
class MplayerPlayer(BasePlayer):
|
||||
@ -338,6 +339,20 @@ class MplayerPlayer(BasePlayer):
|
||||
env = os.environ.copy()
|
||||
if 'TERM' in env:
|
||||
del env['TERM']
|
||||
# On macOS, youtube-dl requires system python to run. Set the environment
|
||||
# to allow that version of python to be executed in the mpv subprocess.
|
||||
if isMacOS():
|
||||
try:
|
||||
pythonLibs = subprocess.check_output(['/usr/bin/python', '-E', '-c',
|
||||
'import sys; print(sys.path)'],
|
||||
text=True, env=dict())
|
||||
pythonLibs = ast.literal_eval(pythonLibs)
|
||||
pythonPath = ':'.join(pythonLibs[1:])
|
||||
except:
|
||||
pythonPath = None
|
||||
if pythonPath is not None:
|
||||
env['PATH'] = '/usr/bin:/usr/local/bin'
|
||||
env['PYTHONPATH'] = pythonPath
|
||||
if filePath:
|
||||
self.__process = subprocess.Popen(
|
||||
call, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
|
Loading…
Reference in New Issue
Block a user