The mission: to build CMD with --onefile and GUI with --onefile. CMD uses
numpy. GUI doesn't use numpy but does use wxPython. GUI calls CMD as a
child process using subprocess.Popen().
The problem: with pyinstaller-2.0 I could build both, and they would run
OK, but calling CMD from GUI gave "Unable to import multiarray errors".
The solution:
1. On Linux I could add a dummy block at the end of GUI.main() to trigger
the import of the CMD and numpy modules into the GUI dist.
if "NO_SUCH_VARIABLE" in os.environ:
import CMD
CMD.main()
Unfortunately this trick didn't work on Windows.
2. Trying to add MERGE statements to the *.spec files. This appeared to
work in that I could gather numpy and wxPython modules into the dist area
with --onedir, but if I tried to set the "name" parameter in the COLLECT
calls to put CMD and GUI executables into the same dist directory, the
second COLLECT would force the removal of what was already there. And while
I could set up the MERGE for the --onefile cases, I still got the "Unable
to import multiarray" error when running CMD from GUI.
3. Reading through all of the articles in the mailing list archive, and
consulting the development version of the documentation, it appeared that
MERGE had been improved/automated. Therefore I downloaded the development
snapshot tarball/zip.
The documentation implies that you can now put both scripts on the
pyinstaller.py command line and pyinstaller will now generate the MERGE
command. So I tried
python pyinstaller.py CMD.py GUI.py
python pyinstaller.py GUI.py CMD.py
in --onedir and then --onefile versions. I was surprised to find that
pyinstaller doesn't generate a MERGE statement in the spec files, BUT all
of the numpy and wxPython modules did appear in the --onedir dist
directories for both CMD and GUI.
The --onefile versions of CMD and GUI both ran, and I could call CMD from
GUI, but there was a bit of a glitch. When CMD terminated, a GUI popped up.
When GUI terminated, a CMD help text appeared in the command window. So
clearly the execution process ran off the bottom of the first executable
and promptly started the other. I solved this by adding explicit
sys.exit(0) calls at the end of CMD.main() and GUI.main().
So now I have a working solution with two --onefile executables, where both
run successfully in isolation, and GUI can also call CMD.
I hope this is useful to someone else.
Good luck.
D.
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/groups/opt_out.