[Python-Dev] PEP 376 - get_egginfo_files

Paul Moore p.f.moore at gmail.com
Sun Jul 5 18:26:07 CEST 2009


The PEP says:

"""
get_egginfo_files(local=False) -> iterator of paths

Iterates over the RECORD entries and return paths for each line if the
path is pointing a file located in the .egg-info directory or one of
its subdirectory.
"""

Should this method really only return filenames noted in the RECORD
file? Would it not be better for it to iterate over *all* files in the
.egg-info directory? I understand that there shouldn't, in practice,
be any files in that directory *not* mentioned in the RECORD file, but
given that we already have get_installed_files to read the RECORD
file, I would imagine it's better for this file to so something more
than filter the return values from get_installed_files.

Actually, on that note, consider the pkgutil functions:

def get_distribution(name):
    for d in get_distributions():
        if d.name == name:
            return d
    return None

def get_file_users(path):
    for d in get_distributions():
        if d.uses(path):
            yield d

These don't actually add much to the API. While I can see the
advantage of having them as convenience methods, it might be worth
pointing out in the PEP that that's all they are.

Similarly, how valuable is Distribution.name, given that it's the same
as Distribution.metadata.name? I'm probably just going to make it a
property -

@property
def name(self):
    return self.metadata.name

but that's actually slower than just using self.metadata.name
directly, so it's a bit of an attractive nuisance, and I'd prefer it
if it wasn't present. (For the PEP 302 stuff, I'm making metadata a
cached property, so name *has* to be a property to ensure that the
metadata cache is managed properly...)

Paul.


More information about the Python-Dev mailing list