[Distutils] pkg_resources: parsing requires.txt without .egg-info/ directory

Sridhar Ratnakumar sridharr at activestate.com
Wed Jul 22 02:27:16 CEST 2009


Ok, I give up.

To parse I need access to the .egg-info/ directory. Why? This is the code  
I currently use to access _dep_map.

>>> import pkg_resources as pr
>>> egg_info = '[...]/src/zope.component.egg-info'
>>> base_dir = os.path.dirname(egg_info)
>>> metadata = pr.PathMetadata(base_dir, egg_info)
>>> dist = pr.Distribution(base_dir,  
>>> project_name=os.path.splitext(os.path.basename(egg_info))[0],  
>>> metadata=metadata)
>>> dist._dep_map

Is there anyway to get access to this parsed _dep_map without having a  
reference to the .egg-info directory? After all, everything needed to  
parse requires.txt is that file alone.

Note: requires.txt is extracted and stored elsewhere, so I cannot rely in  
it being inside .egg-info/ directory in order to parse it.

-srid

On Tue, 21 Jul 2009 17:07:45 -0700, Sridhar Ratnakumar  
<sridharr at activestate.com> wrote:

> On Mon, 20 Jul 2009 19:46:49 -0700, P.J. Eby <pje at telecommunity.com>  
> wrote:
>
>> At 05:39 PM 7/20/2009 -0700, Sridhar Ratnakumar wrote:
>> I've already looked into that before (in pkg_resources.py) -
>> unfortunately, this does not return all of requires.txt (as Python dict,
>> that is), but only *what* you specify in the 'extras' argument (how am I
>> supposed to know the /possible/ extras sections beforehand?).
>>  Ah, you didn't say that, you just said "parse".  If you'll file a  
>> feature request, I'll replace _dep_map with a public attribute for  
>> accessing that information in a future release.  In the meantime,  
>> you're quite safe using ._dep_map, since obviously I'm not going to  
>> change it out from under you.
>
> Done - http://bugs.python.org/setuptools/issue82
>
> And it is `_Distribution__depmap`, not '_dep_map'.
>
> -srid
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig




More information about the Distutils-SIG mailing list