If that works for you?
Thanks in advance.
Brian píše v Po 03. 10. 2011 v 16:22 -0700:
Where could I download opencv package?
Your getopencv example is working when I add there explicit import of
numpy module.
Pyintaller is not able detect opencv dependencie because cv2.pyd is a
native binary not a compiled python code.
We would need to create an import hook for cv module.
Could you please try to create import hook hook-cv.py with numpy or
maybe other necessary modules as hidden imports?
If it will work we could include it with other pyinstaller hooks.
Yes, that's exact.
>
>
> On another note, I have not researched this yet, but I've encountered
> a regression and PyInstaller is one of the view things that has
> changed between versions. Is it possible that a recent change could
> result in something strange going on with multiprocessing, especially
> multiprocessing queues? Don't research this just yet, because I have
> yet to confirm that pyinstaller is the only variable.
Are you experiencing issues like:
http://www.pyinstaller.org/ticket/182
http://www.pyinstaller.org/ticket/146
Could you please put together a small multiprocessing example which
would reproduce the issue?
BTW, I didn't know there is freeze_support() function in python. We
should mention that in the manual.
The same is valid for me. Thanks for the example. I'll see what I can do
about it.
I can confirm that your issue is related to this bug:
http://www.pyinstaller.org/ticket/182
If I did the following change and recompilled bootloader then your
example seems working.
Could you please recompile bootloader with the foolowing change and let
me know if your app works then?
If you want me to send you compilled bootloader with this change, let me
know.
--- source/common/launch.c (revision 1609)
+++ source/common/launch.c (working copy)
@@ -1296,7 +1296,7 @@
* as subprocess, this subprocess will not fooled into thinking that
it
* is already unpacked.
*/
- unsetenv("_MEIPASS2");
+ //unsetenv("_MEIPASS2");
/* Iterate through toc looking for scripts (type 's') */
while (ptoc < status->tocend) {
While this may show another issue about compiling r1609, there should be
a solution which does not require recompiling the loader.
Please check my today's comment on http://www.pyinstaller.org/ticket/182
and the attachment. (I can not test it myself, since I have no Windows
machine at hand).
--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP
Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de
Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult ist Mitglied bei http://www.7-it.de
Sure, but i was in a hurry ;-) I wanted to post the basic idea anyway.
> there is no multiprocessing.forking.Popen class
These is, see `pydoc multiprocessing.forking.Popen`, just the import was
wrong. One needs to import multiprocessing.forking explicitly.
You must not inherit from subprocess.Popen, which, is a different
implementation. See multiprocessing.forking. This is why your code fails.
I've just uploaded an new version which works (unpackaged) on Linux.
Please try this.
I changed the code to this:
Doing so caused an error (from PyInstaller code, IIRC) about a key not
being in a dictionary ('_Popen' being the key, and the class the dictionary?)
I don't know what value of _MEIPASS2 should be used. Notice that I
You said, your original program did run when built with --onedir, didn't
it? So we already have a problem here.
> test_multiprocess.py does not work when built with --onefile
This is what I expected
> test_multiprocess_2.2.py works unpackaged
This is good.
> test_multiprocess_2.2.py does not work when packaged with --onedir
This is not so good :-(
> File "C:\Users\b\p\tst\d\pyinstaller-r1641\PyInstaller\iu.py", line
> 71, in __init__
> raise OwnerError("%s is not a directory" % path)
> iu.OwnerError:<OwnerError --dummy- is not a directory>
Thanks for your other tests here. Somebody has to look much deeper into
the code and follow the control-flow. I'll not have time for this
before the end of this week -- and I still do not have a Windows
development environment :-)
Perhaps you can try to find out a bit more. One central point is
source/common/launch.c and as it looks PyInstaller\iu.py, too.
You may try this patch to solve the '--dummy--' problem:
===================================================================
--- PyInstaller/archive.py (Revision 1649)
+++ PyInstaller/archive.py (Arbeitskopie)
@@ -428,7 +428,7 @@
except AttributeError:
raise ImportError, "PYZ entry '%s' (%s) is not a valid
code object" % (nm, repr(co))
if ispkg:
- if '_MEIPASS2' in _environ:
+ if '_MEIPASS2' in _environ and _environ['_MEIPASS2'] !=
'--dummy--']:
localpath = _environ['_MEIPASS2'][:-1]
else:
localpath = iu._os_path_dirname(self.path)
So the issue here is to get test_multiprocess_2.2.py working on WinXP
when frozen, right?
I think I could find some time this evening or tomorrow.
I tried test_multiprocess_22.py on winxp. But it didn't work. It was
failing because of '--dummy--' in PYTHONPATH.
I'm not sure where to start with debugging.
When trying the patch I got the following traceback:
-------------------------------------------------------
Z:\tmp\pyi_trunk>.\test_multiprocess_2.2\dist\test_multiprocess_2.2
\test_multipr
ocess_2.2.exe
_MEIPASS2 is NULL
Extracting binaries
Executing self as child with Setting up to run child
Creating child process
Waiting for child process to finish...
_MEIPASS2 is Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist
\test_multiprocess_2.2\
Already in the child - running!
manifestpath: Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist
\test_multiprocess_2.2\
test_multiprocess_2.2.exe.manifest
Activation context created
Activation context activated
Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist\test_multiprocess_2.2
\python27.dll
Manipulating evironment
PYTHONPATH=Z:/tmp/pyi_trunk/test_multiprocess_2.2/dist/test_multiprocess_2.2
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
pyb
Traceback (most recent call last):
File "<string>", line 33, in <module>
File "<string>", line 21, in __init__
File "Z:\tmp\pyi_trunk\test_multiprocess_2.2\build\pyi.win32
\test_multiprocess
_2.2\outPYZ1.pyz\multiprocessing.process", line 130, in start
File "<string>", line 7, in __init__
OSError: [Errno 42] Illegal byte sequence
RC: -1 from test_multiprocess_2.2
OK.
Deactivating activation context
Releasing activation context
Done
Back to parent...
Freeing status for Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist
\test_multiprocess
_2.2\test_multiprocess_2.2.exe
Previously I run wrong code example. When applying patch for --dummy--
this is the output. There is only error in activating context.
---------------------------------------------------
pyb
OK.
Deactivating activation context
Releasing activation context
Done
Back to parent...
Freeing status for Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist
\test_multiprocess
_2.2\test_multiprocess_2.2.exe
_MEIPASS2 is --dummy--
Z:\tmp\pyi_trunk>Already in the child - running!
manifestpath: --dummy--test_multiprocess_2.2.exe.manifest
Error activating the context
Z:\tmp\pyi_trunk\test_multiprocess_2.2\dist\test_multiprocess_2.2
\python27.dll
Manipulating evironment
PYTHONPATH=--dummy-;Z:/tmp/pyi_trunk/test_multiprocess_2.2/dist/test_multiproces
s_2.2
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
SendeventProcess
SendeventProcess
os.path.dirname(os.path.abspath(sys.executable)) could also work.
That's what I'm not sure. For this I would like to get some input from
someone more experienced.
I tried to set _MEIPASS2 to
os.path.dirname(os.path.abspath(sys.executable)) and it seems to work
correctly.
Attached is the multiprocess code that works for me on winxp without any
context error. Could you test it please?
If it works we should create from this example a test case for
pyinstaller.
Output when running on winxp:
--------------------------------------------------
Z:\tmp\pyi_trunk>.\test_multiprocess_2_2\dist\test_multiprocess_2_2
\test_multiprocess_2_2.exe
_MEIPASS2 is NULL
Extracting binaries
Executing self as child with Setting up to run child
Creating child process
Waiting for child process to finish...
_MEIPASS2 is Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
Already in the child - running!
manifestpath: Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
test_multiprocess_2_2.exe.manifest
Activation context created
Activation context activated
Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist\test_multiprocess_2_2
\python27.dll
Manipulating evironment
PYTHONPATH=Z:/tmp/pyi_trunk/test_multiprocess_2_2/dist/test_multiprocess_2_2
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
pyb
pyb
OK.
Deactivating activation context
Releasing activation context
Done
Back to parent...
Freeing status for Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess
_2_2\test_multiprocess_2_2.exe
Z:\tmp\pyi_trunk>_MEIPASS2 is Z:\tmp\pyi_trunk\test_multiprocess_2_2
\dist\test_m
ultiprocess_2_2\
Already in the child - running!
manifestpath: Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist
\test_multiprocess_2_2\
test_multiprocess_2_2.exe.manifest
Activation context created
Activation context activated
Z:\tmp\pyi_trunk\test_multiprocess_2_2\dist\test_multiprocess_2_2
\python27.dll
Manipulating evironment
PYTHONPATH=Z:/tmp/pyi_trunk/test_multiprocess_2_2/dist/test_multiprocess_2_2
IC, this is a lace I've overseen since I was grepping for _MEIPASS2
Documented in http://www.pyinstaller.org/wiki/Recipe/Multiprocessing
Brian, if the recipe (example) does not work for you
http://www.pyinstaller.org/wiki/Recipe/Multiprocessing
please reopen the following ticket:
http://www.pyinstaller.org/ticket/182
It works fine in --onedir mode. However for --onefile there are some
issues.
One minor issue was that we need to get correct _MEIPASS value. And we
can't get it from dirname(sys.executable). I fixed the Recipe to get the
right value from PYTHONPATH.
However, another issue is that the main process is not waiting for the
multiprocess subprocesses to finish their activity!
- not frozen python code is waiting for multiprocess subprocesses)
- the multiprocess subprocess then fails becase it can't find
libpython.dll
- that's because at that time main process is gone and files unpacked
into tmp dir are already deleted
We need to find a way how to wait in main process for multiprocess
subprocesses.
I reopened the ticket #182.
Martin
Argl. Reading this thread I thought, it does.
> One minor issue was that we need to get correct _MEIPASS value. And we
> can't get it from dirname(sys.executable). I fixed the Recipe to get the
> right value from PYTHONPATH.
This will fail if sys.path was changed in the meantime. I propose
changing the loader to store the value somewhere else. E.e. in sys._MEIPASS.
> However, another issue is that the main process is not waiting for the
> multiprocess subprocesses to finish their activity!
So we need dome kind of `wait`. Maybe this could help at the end of
__main__:
while multiprocessing.active_children():
multiprocessing.active_children()[0].join()
This would be fine.
This works. I'll update the recipe.
I think we have a working example.
Fine.
> I think we have a working example
Please mind closing #182 then,
what about the sys._MEIPASS?
I forgot. Unfortunalty I'm not the C-programmer in our team ;-)
We could unset _MEIPASS in the iu.py file during bootstrap process and
not directly in the loader?
> I forgot. Unfortunalty I'm not the C-programmer in our team ;-)
Me too :)
Good idea. This should work (while I have to look at the source first.)
Moving as much logic into Python code as possible eases maintenance.
>> I forgot. Unfortunalty I'm not the C-programmer in our team ;-)
> Me too :
*calling* Gioooovaaaanniiiiii ;-)