[Distutils] SETUPTOOLS - Loading Eggs which do not have an egg_info

Ilias Lazaridis ilias at lazaridis.com
Thu Dec 7 20:45:14 CET 2006

Ilias Lazaridis wrote:
> Phillip J. Eby wrote:
>> At 06:24 PM 12/7/2006 +0200, Ilias Lazaridis wrote:
>>> Looks somehow like this:
> ...
>>> How can I create an egg representing object (from the sources/setup.py),
>> >from which I can load the entry-points afterwards, without having to
>>> generate an egg_info on the file-system?
>> You can take the dist.Distribution object's entry_points and parse it to 
>> create an entry point map.
> ...
>> I can't guarantee that there aren't other things that will break, too.  I 
> ... (elaborations)
> I understand, and I basicly would like to use the setuptools egg code.
> This is a special and limited use-case:
> The eggs do *not* need to be found by other eggs/applications, as they 
> are used only by the application that loads them in.
> Thus I just want to create the egg representation in my code (to call 
> the entry_points), whilst using the information from setup.py/sources 
> (instead of the generated egg_info).
> Essentially, the code (internal in setuptools) that reads the egg_info 
> will simply retrieve it from the setup.py (or i instantiate it somhow, 
> and pass it to the setuptools routines)
> The function would be essentially:
> def get_an_egg(path_to_setuppy)
>    # load setup.py
>    # construct the egg
>    return egg
> #further processing based on standard egg methods


I am a little overworked at this point, but this should be the right 
direction to enable setuptools to create distributions whilst using the 
information within setup.py (and without breaking any behaviour):

in pkg_resources

def register_finder(importer_type, distribution_finder):
     """Register `distribution_finder` to find distributions in sys.path 

     _distribution_finders[importer_type] = distribution_finder

def find_distributions(path_item, only=False):
     """Yield distributions accessible via `path_item`"""
     importer = get_importer(path_item)
     finder = _find_adapter(_distribution_finders, importer)
     return finder(importer, path_item, only)



More information about the Distutils-SIG mailing list