-
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.)
Upgrade your wexpect to v4.0.0 or higher. This is the first version that uses the new-structured spawn class as the default spawn class.
(You can use the pyinstaller from wexpect v3.3.0, but in this case, you have to choose the new-structured spawn class by setting the WEXPECT_SPAWN_CLASS
environment variable to 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
└─ ...