How do I integrate my import hook with iu.py? I think pyinstaller is
ignoring my hook and thus can't package my program.

relevant code below: (note might not work as shown)

def addwidgetzip(ppath):
    wx = info about each widget
    widgetrep.append(wx)
    updateAll()


class wimp(object):
    def __init__(self,a):
        self.path = a
        self.support = cmap

    def load_module(self, fullname):
        wn = fullname.replace('uxGUI.widgets.','')

        if fullname in sys.modules:
            return sys.modules[fullname]

        nfo = self.support[wn]

        zz = os.path.basename(nfo['code'])
        n,e = os.path.splitext(zz)


        if 'zip' in nfo.keys() and nfo['zip'] == True:
            print "zip"
            module = sys.modules.setdefault('uxGUI.widgets',
imp.new_module('uxGUI.widgets'))


            d = module
            zd = nfo['zipdata']
            zd = zd.splitlines()
            zd = "\n".join(zd) + "\n"

            ff = open('z.py','w')
            ff.write(zd)
            ff.close()
            print fullname
            code = compile(zd, nfo['zipfilename']+'/'+fullname,
'exec')
            exec code in module.__dict__
sys.path_hooks.remove(wimp)
        c = getattr(d,nfo['class'])

        sys.modules[fullname] = c
        return c

    def find_module(self, fullname, path=None):
        wn = fullname.replace('uxGUI.widgets.','')
        if wn in self.support.keys():
            return self
        else:
            return None

def updateAll():
    global widgetsavailable,__all__
    widgetsavailable = []
    __all__ = ['widgetsavailable']

    for wx in widgetrep:
        cmap[wx['classname']] = wx

    sys.path_hooks.append(wimp)
    sys.path_importer_cache.clear()

    for wx in widgetrep:
        cmap[wx['classname']] = wx

        __import__('uxGUI.widgets', globals(), locals(),
[wx['classname']])
        __all__.append( wx['classname'] )
        widgetsavailable.append(wx['classname'])

    sys.path_hooks.remove(wimp)

zloc = 'C:\uxpython\exe\dist\widgets.zip'
addwidgetzip(zloc)

-----------------------
It works fine before pyinstaller. So i just need to tell pyinstaller
about my import hook - wimp

Also if someone can tell me how to add the default import mechanism to
sys.path_hooks so I dont have to sys.path_hooks.remove(wimp) that
would be awesome.

--~--~---------~--~----~------------~-------~--~----~
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