[Distutils] RFC : PEP 376 - egg.info

David Lyon david.lyon at preisshare.net
Tue May 5 02:32:43 CEST 2009

On Tue, 5 May 2009 02:11:36 +0200, Tarek Ziadé <ziade.tarek at gmail.com>
> I am not sure to understand what you are explaining - when the python
> interpreter starts up, it doesn't load every installed package
> in memory. the loading happens when you do "import foo"

Correct. I didn't say it loads them all. 

The code however seems to load up all the names of the packages
from packages along the python-path. It then executes any
line starting with 'import'.

--- http://svn.python.org/projects/python/trunk/Lib/site.py -----
def addpackage(sitedir, name, known_paths):
    """Process a .pth file within the site-packages directory:
       For each line in the file, either combine it with sitedir to a path
       and add that to known_paths, or execute it if it starts with 'import
    if known_paths is None:
        reset = 1
        reset = 0
    fullname = os.path.join(sitedir, name)
        f = open(fullname, "rU")
    except IOError:
    with f:
        for line in f:
            if line.startswith("#"):
            if line.startswith(("import ", "import\t")):
                exec line
            line = line.rstrip()
            dir, dircase = makepath(sitedir, line)
            if not dircase in known_paths and os.path.exists(dir):
    if reset:
        known_paths = None
    return known_paths


> *without having to load this module in your interpreter*, because this
> info is writtent in a static text file located in the .egg-info
>  directory. After, you will eventually load it (by using a load()
> function in the entry point, that is basically an import statement)

Yes .. that perfectly describes existing functionality.

> But entry points provides a way to tell you for example that the "bar"
> function located in the "foo" module is a plugin,

I see now what you are getting at...

But packages along the site-packages directory are already a form of
a plug-in system. It just doesn't have the modern name.

The code is already implemented as shown above.. it all works "today"..

What really is missing is the sophisticated API to properly manage
it all. There's no way to find out what's installed... remove anything..

The whole system is very brittle...

I think it's possible to come up with something "new" by just addressing
many of the major deficiencies that already exist in distutils. 

For me personally - I'm a big admirer of the existing code..

problem to me seems to be there's just not enough of it..


More information about the Distutils-SIG mailing list