-
Notifications
You must be signed in to change notification settings - Fork 23
Wexpect with pyinstaller
The legacy wexpect was compatible with py2exe, but the latest version of py2exe has been released in 2014! So based on several requests (see #12) the pyinstaller support has been implemented in version v3.3.0 (While the py2exe support has been removed.)
First, be sure, that you use wexpect v3.3.0 or higher.
First, the legacy-wexpect does not support pyinstaller (and it will not support in the future.) So switch to one fo the new-structured wexpect, by setting the WEXPECT_SPAWN_CLASS
environment variable to SpawnPipe
. Enter set WEXPECT_SPAWN_CLASS=SpawnPipe
in Windows' CMD, or writeos.environ['WEXPECT_SPAWN_CLASS']='SpawnPipe'
in python before importing wexpect. After this modification, please test your code without pyinstaller, because some feature has not been implemented in SpawnPipe
.
Because wexpect uses a console-reader subprocess to manipulate the child's console, you have to create and place this, console-reader or wexpect executable beside your application. To create wexpect executable download/clone wexpect from GitHub. There is a wexpect.spec
pyinstaller spec file in the repo's folder. Start pyinstaller with this file: pyinstaller wexpect.spec
. This will create the console-reader executable. The freeze of the wexpect has to run once per wexpect versions. This console-reader executable must be delivered with your script's executable.
Finally, freeze your script with pyinstaller with pyinstaller your_script.py
. Place wexpect's bundle beside your scrip's bundle.
dist
├─wexpect
│ ├─ ...
│ ├─ wexpect.exe
│ └─ ...
└─your_script
├─ ...
├─ your_script.exe
└─ ...