[Distutils] SETUPTOOLS - Loading Eggs which do not have an egg_info
Phillip J. Eby
pje at telecommunity.com
Thu Dec 7 18:14:40 CET 2006
At 06:24 PM 12/7/2006 +0200, Ilias Lazaridis wrote:
>Looks somehow like this:
>
>
>from distutils.core import run_setup
>dist = run_setup( setuppys[0],None,'init')
>print dist
>
>loaded_components = []
>module = []
>
>import pkg_resources
>for name in pkg_resources.get_entry_map(dist,'trac.plugins'):
> entry_point =
>pkg_resources.get_entry_info(dist,trac.plugins', name)
> entry_point.load()
>
>but this fails, I must have missed some point.
>
>(('Expected string, Requirement, or Distribution', ))
>
>although "dist" is an:
>
><setuptools.dist.Distribution instance at 0x0187E260>
That Distribution is a distutils distribution, not a pkg_resources
distribution.
>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]
There are several big drawbacks to this approach, because you're basically
bypassing the entire eggs system. Here are two of the things that will
break when you do this:
* Plugins will not be able to depend on other plugins
* Plugins will not be able to depend on other Python packages or projects
I can't guarantee that there aren't other things that will break, too. I
don't recommend that you use this approach in a published or production
system, just because you don't like generating the egg-info on disk. It's
there for several reasons, not the least of which is that it allows you to
ship plugins as single .egg files. See also:
http://peak.telecommunity.com/DevCenter/PkgResources#locating-plugins
which shows how to do automatic plugin discovery and dependency
resolution. This is another example of something that won't work with the
approach you're trying to use.
More information about the Distutils-SIG
mailing list