[Distutils] imp.find_modules and namespaces

Alessandro Dentella sandro at e-den.it
Mon Feb 11 17:40:42 CET 2013


Hi,

I believe that this issue belongs to this list, please let me know if I'm
wrong. 

Suppose I have 2 packages:

  jmb.foo
  jmb.bar

distributed separately. Each has in jmb's __init__ a standard:

  
  __import__('pkg_resources').declare_namespace(__name__)

or

  from pkgutil import extend_path
  __path__ = extend_path(__path__, __name__)
  

I just realized that imp.find_module() will return "fake" values

  imp.find_module('jmb', None)

may return (a tuple with) the path from the first package or from the
second. Many framework will fail to discover commands in the inner module:
one is detailed here [1] another is Django way of getting application's
commands. 

I find it misleading to return a value that is not thorohly correct.

Is there a workaround? Is the current behaviour considered correct for
reasons I don't yet understand?

thanks in advance
sandro
*:-)


[1] http://stackoverflow.com/questions/5741362/alternatives-to-imp-find-module?answertab=votes#tab-top

-- 
Sandro Dentella  *:-)
http://www.reteisi.org             Soluzioni libere per le scuole
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy





More information about the Distutils-SIG mailing list