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

Ilias Lazaridis ilias at lazaridis.com
Thu Dec 7 19:57:19 CET 2006


Phillip J. Eby wrote:
> At 06:24 PM 12/7/2006 +0200, Ilias Lazaridis wrote:
>> Looks somehow like this:
...
>> <setuptools.dist.Distribution instance at 0x0187E260>
> 
> That Distribution is a distutils distribution, not a pkg_resources 
> distribution.

ok

>> 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.
> 
> See 
> http://peak.telecommunity.com/DevCenter/PkgResources#creating-and-parsing 
> for details.  In particular, you want to use:
> 
>       ep_map = EntryPoint.parse_map(dist.entry_points)
>       entry_point = ep_map['trac.plugins'][name]

Although not the prefered solution, I've tried this:

         import pkg_resources
         from distutils.core import run_setup
         dist = run_setup( setuppys[0],None,'init')

         ep_map = pkg_resources.EntryPoint.parse_map(dist.entry_points, 
dist)

         ep_list = ep_map['trac.plugins']
         print ep_list

         for name, entry_point in ep_list.iteritems():
             print name
             print entry_point
             try:
                 entry_point.load()
             except pkg_resources.DistributionNotFound, e:


...
   File 
"C:\prg\py24\lib\site-packages\setuptools-0.6c3-py2.4.egg\pkg_resources.py", 
line 1829, in load
     if require: self.require(env, installer)
   File 
"C:\prg\py24\lib\site-packages\setuptools-0.6c3-py2.4.egg\pkg_resources.py", 
line 1842, in require
     working_set.resolve(self.dist.requires(self.extras),env,installer))
AttributeError: Distribution instance has no attribute 'requires'


> There are several big drawbacks to this approach, because you're basically 
> bypassing the entire eggs system.  
... (elaborations)


.

-- 
http://lazaridis.com



More information about the Distutils-SIG mailing list