[Python-ideas] package based import

Ronny Pfannschmidt Ronny.Pfannschmidt at gmx.de
Sun May 6 09:48:46 CEST 2012


Hi,

this one is still prety rough (not just on the edges)

after some tinkering with tools like nmp,

i got the idea of package based imports

the idea is to have a lookup based on package toplevel names firs, 
instead of just walking sys.path

that way it becomes more natural for packages to be in a own dir instead 
of everything being merged in site-packages
and of course, much less files to walk to find a particular package, 
since the mapping of package name to import paths is already known

in order to add such ackages, some kind of registration would be necessary


a basic example could be something like

packages.pth::
   import pkgutil
   # whereever _init__.py is
   pkgutil.register_package('flask', '~/Projects/flask/flask')
   pkgutil.register_module('hgdistver', '~/Projects/hgdistver.py')

alltough for convience a ini file with sections and doted name to path 
mappings might be better.

once that is in place that opens up the path for fun local envs
like simply looping over eggs/dirs in a packages subdir and adding them,
instead of needing buildout/virtualenv

-- Ronny





More information about the Python-ideas mailing list