I followed your example:
Tried converter.py, still using my hook (because I know it hoes inside it :)
), I see the print entering in the hook and I added following 
Hidden imports:
print
"***************************************************************************
**********"

hiddenimports = [
    'enthought.pyface.api',
    'enthought.pyface.toolkit',
    'enthought.pyface.ui.null',
    'enthought.pyface.ui.wx',
    'enthought.pyface.ui.qt4',
    'enthought.traits'        #this one is the important one
]

On my system:
In [5]: import enthought.traits as e

In [6]: e.__path__
Out[6]:
['C:\\Python26\\lib\\site-packages\\traits-3.2.0-py2.6-win32.egg\\enthought\
\traits',
 
'C:\\Python26\\lib\\site-packages\\traitsbackendqt-3.2.0-py2.6.egg\\enthough
t\\traits',
 
'C:\\Python26\\lib\\site-packages\\traitsbackendwx-3.2.0-py2.6.egg\\enthough
t\\traits',
 
'C:\\Python26\\lib\\site-packages\\traitsgui-3.1.0-py2.6.egg\\enthought\\tra
its']

Wow why did they do such a complex thing!

Running converter.exe I get:
Traceback (most recent call last):
  File "<string>", line 18, in <module>
  File
"C:\Users\Laurent\Projets\DTSQ\Def\Soft\Scripts\external_apps\pyinstaller\iu
.py", line 458, in importHook
    raise ImportError, "No module named %s" % fqname
ImportError: No module named enthought.traits
RC: -1 from converter

Hum, so what could be the problem?
The system don't find the enthougth.traits while it has been declared as
hidden imports?
(seems confirmed by warnconverter.txt generated by spec file:
W: no module named enthought.traits (top-level import by enthought)
...

So I think I need to make pyinstaller find the module in the right place.
(Manipulating path?)
Do you share my analysis?

Laurent

-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De
la part de Antonio Valentino
Envoyé : dimanche 24 janvier 2010 20:48
À : PyInstaller
Objet : [PyInstaller] Re: Now having even more fun.

Hi Laurent,

Il giorno Sun, 24 Jan 2010 16:21:38 +0100
"Laurent Dufrechou" <[email protected]> ha scritto:

> Hello all,
>
> So i'm trying to do an enthought hook.
> I've staretd to read doc on hook.
> So far I've managed to have a hook-enthought file and the hook is
> triggered by my script:

please, can you tell me id the main enthought directory has a
__init__.py file inside?


> print "in enthought hook!"
> def hook(mod):
>     import enthought
>     if hasattr(enthought, "__path__"):
>         import sys
>         for p in enthought.__path__:
>             sys.path.insert(1,p)
>     print sys.path
>     return mod
>
> First thing I've done is to add all enthougth package to system path.

I'm not sure this is strictly needed.

> But now I don't understand what is next phase.
>
> 1/pyinstaller see "from enthought.mayavi.core.ui.api import
> MayaviScene, ... "
> 2/pyinstaller start to scan 'enthought.mayavi'
> So it call analyse_r('enthought.mayavi') that call
> analyse_one('enthought') and the hook is triggered.
>
> So what is the next step?

In my tests I started with something very simple:

converter.py
cursor_tool_demo.py

from the Traits/Chaco example directory.
In my case the next step was to collect the backend modules (wx or
qt4).
enthought uses a dynamic import mechanism so not all backend modules
are collected by pyinstaller out of the box.

Here it is a hook for pyface "hook-enthought.pyface.py"

### hook-enthought.pyface.py ###
hiddenimports = [
    'enthought.pyface.api',
    'enthought.pyface.toolkit',
    'enthought.pyface.ui.null',
    'enthought.pyface.ui.wx',
    'enthought.pyface.ui.qt4',
]

from hooks.hookutils import exec_statement

def pyface_suport(backend):
    code = (
        r'from enthought.etsconfig.api import ETSConfig; '
        r'ETSConfig.toolkit = \"%s\"; '
        r'import enthought.pyface.api; '
        r'import sys; '
        r'mods = [m for m in sys.modules if
m.startswith(\"enthought.\")]; ' r'print sorted(mods)') % backend

    return eval(exec_statement(code))

def fix_pyface_backends(himports):
    #null = [name for name in pyface_suport('null') if name not in
himports]
    #himports.extend(null)
    #wx = [name for name in pyface_suport('wx') if name not in
himports]
    #himports.extend(wx)
    qt4 = [name for name in pyface_suport('qt4') if name not in
himports]
    himports.extend(qt4)

fix_pyface_backends(hiddenimports)
### end hook-enthought.pyface.py ###

This hook should collect all modules needed by the pyface.api for the
qt4 backend.

All *.ui sub-packages should have pyface as hidded import

hiddenimports = ['enthought.pyface']

If I remember well the hook works quite goot but the example still
doesn't work since still miss resources.


[CUT]


> The thing I've seen is that every path in enthought.__path__ contains
> a __init__.py, so I suspect I need to do something with them?


IMHO you don't need to do nothing special with them.
I'm just curious how did you installed enthought and which is your
platform.
In my installation (ubuntu 9.10 x86_64 with standatd packages) there
is
no __init__.py file.
Also installing enthought from sources the situation seems to be the
same.


> Thx for any help!
>
> Laurent
>
> -----Message d'origine-----
> De : [email protected]
> [mailto:[email protected]] De la part de Antonio Valentino
> Envoyé : mercredi 13 janvier 2010 10:58
> À : PyInstaller
> Objet : [PyInstaller] Re: Now having even more fun.
>
> Hi Laurent,
>
> On Jan 13, 10:29 am, Laurent Dufrechou <[email protected]>
> wrote:
> > Hi antonio,
> >
> > I saw your previous emails on the subject :) Can you send me the
> > work you did before on hooks?
>
> Unfortunately I don't remember if i saved it.
> I should look in my backups at home.
>
> Anyway I can say that there was a hierarchy of hooks for all enthought
> components (at leas all the one I was interested in).
> As a starting point for my hooks I used
>
> http://www.pyinstaller.org/browser/trunk/hooks/hook-PIL.Image.py
> http://www.pyinstaller.org/browser/trunk/hooks/shared_PIL_Image.py
>
> If I remember well I also added some machinery for backend selection.
>
> > To be honest I'm very newbie with hook mechnism, so it will help me
> > a lot!
> >
> > For point 3, don't know if it is related to patch in ticket39, but
> > currently, manifest are currently well handled so far on my
> > platform (python26/win32).
>
> Please look at
>
>
http://groups.google.com/group/pyinstaller/browse_thread/thread/cffcb4ccb024
> 1b75/cd2226f0f941c618?hl=en&lnk=gst&q=valentino#cd2226f0f941c618

Best regards.

--
Antonio Valentino

-- 
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyinstaller?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to