Introduce WEXPECT_EXECUTABLE environment variable for pyinstaller

Last versions searched wexpect executable ../wexpect/wexpect.exe in
bindled mode. This was hard coded. Now the (optional) WEXPECT_EXECUTABLE
environment variable can point to wexpect executable.

See #12 for more details.
This commit is contained in:
Benedek Racz 2020-04-09 10:02:04 +02:00
parent 8ce9059388
commit af8d24df1d

View File

@ -342,10 +342,20 @@ class SpawnBase:
raise Exception(
'`sys.frozen` found, but `sys._MEIPASS` not. Only pyinstaller is supported.'
)
dirname = os.path.dirname(sys.executable)
console_executable = os.path.join(dirname, '..', 'wexpect', 'wexpect.exe')
commandLine = f'"{console_executable}" {console_args}'
#
# Find wexpect executable (aka. console reader executable).
# User can point WEXPECT_EXECUTABLE environment variable to this executable, if this
# env/var isn't specified we will find executable `../wexpect/wexpect.exe` relativly
# from the host executable.
#
try:
wexpect_executable = os.environ['WEXPECT_EXECUTABLE']
except KeyError:
dirname = os.path.dirname(sys.executable)
wexpect_executable = os.path.join(dirname, '..', 'wexpect', 'wexpect.exe')
commandLine = f'"{wexpect_executable}" {console_args}'
else:
'''Runing in a normal python process