Steve Lee <[EMAIL PROTECTED]> wrote:

> Right my problem: I have a COM client that needs to use the early
> binding gen_py modules and so uses gencache.EnsureDispatch() rather
> that the usual Dispatch() which falls back to Dynamic/late binding.
> This is mainly coz Mark Hammond told me to :-| (I use COM constants
> and event sinks).

I'm not fluent with win32com, I barely used Dispatch() once. Mind explaining
the difference between the two? Basically, I knew of two different ways:

- Using Dispatch() (fully dynamic)
- Generate the wrapper with makepy.py, import it with "import Foo", and use the
classes it exports directly.

I never heard of EnsureDispath.

> The problem is that the modules are NOT found in the pyinstaller
> gen_py folder.

Does PyInstaller know in the first place there is a dependency on that module?
In your repro case, you don't import anything specific, so I guess PyInstaller
has no ways of knowing that you'll be importing that module. Does it work if
you add "import win32com.gen_py.C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x0" in
your test file?

> This is actually hidden on a dev machine as it picks
> them up from the lib\win32com or %temp% gen_py folders so you have to
> delete them first to show the problem.  This then repros the target
> machine setup where the users doesn't have a python distro installed.
> This all works fine when using Dispatch().

I guess because Dispatch() really doesn't need any external module, but
directly find and inspect the .DLL.

> OK this minimal code, which should work on any XP box, shows the
> problem
>
> from win32com.client.gencache import EnsureDispatch
> v = EnsureDispatch("Sapi.SpVoice") # Dispatch() is fine
> v.Speak( "Hello.")

One problem is that I don't have a development XP machine handy, and I don't
know COM enough. Can you construct a different testcase which doesn't strictly
require XP? I guess connecting to any older COM dll is good to reproduce...

> ImportError: No module named
> win32com.gen_py.C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x0

As I read it, PyInstaller doesn't know it needs to package this module.

> I initially thought it was the fact that the _GetModule() looks for
> win32com.gen_py.<CLSID> and that is not the path under the pyInstaller
> created 'support' folder but it seems to work OK for Dispatch(), I
> guess via these mysterious hooks.

It's not that "mysterious" :) You can have a look at
support/rthooks/win32comgenpy.py which is the module that is run before your
code starts. You will see that it creates the local gen_py folder, and
monkey-patch it into win32com.__gen_path__.

> BTW the fact that pyInstaller uses it's own gen_py folder is better
> than py2exe as it reduces interactions with the python installation
> or user copies causing differences between dev and target machines.

Yes, that's good in fact.

Giovanni Bajo

_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller

Reply via email to