I really think this will be good, especially if it can be installed in
web2py/site-packages folder.

Will this mean that we may end up with web2py being a platform for
developing Windows applications since it can by-pass the "need" to
install Python on Windows?

ML

On Dec 30, 12:47 pm, mdipierro <[email protected]> wrote:
> How about some code that is you try o timport a module that is not
> installed, trys to ez_install it?
>
> import sys, imp
> from ez_setup import use_setuptools
> use_setuptools()
> from setuptools.command.easy_install import main
>
> class SmartImporter(object):
>     tried_modules=set()
>     domain_modules = set()
>
>     def find_module(self, fullname, path=None):
>         if fullname in self.domain_modules:
>             return self
>         if fullname in self.tried_modules:
>             return None
>         else:
>             self.tried_modules.add(fullname)
>             try:
>                 main([fullname])
>                 return self
>             except:
>                 return None
>
>     def load_module(self, fullname):
>         if fullname in sys.modules:
>             return sys.modules[fullname]
>         mod = imp.new_module(fullname)
>         mod.__loader__ = self
>         sys.modules[fullname] = mod
>         if fullname not in self.domain_modules:
>             self.domain_modules.add(fullname)
>         return mod
>
> sys.meta_path = [SmartImporter()]
>
> import tornado # is not installed should install it!
> print tornado
>
> This does not quite works. I could use some help.
>
> Massimo

Reply via email to