On Tue, Nov 17, 2015 at 9:35 AM, Donald Stufft <donald(a)stufft.io> wrote:
> On Nov 17, 2015, at 9:26 AM, Neal Gompa <ngompa13(a)gmail.com> wrote:
>
> The dependency generator uses pkg_resources (specifically
> Distribution, FileMetadata, PathMetadata) to read data in the
> .egg-info directory. That should still work with .dist-info, right? If
> it does, then I can easily support it to read and parse the data. If
> there's something else I have to do, please let me know, so I can add
> it.
>
That’s correct. There’s a EggInfoMetadata class and a DistInfoMetadata
class in pkg_resources.
So the code to pull the metadata works like this:
if lower.endswith('.egg') or \
lower.endswith('.egg-info') or \
lower.endswith('.egg-link') or \
lower.endswith('.dist-info'):
from pkg_resources import Distribution, FileMetadata, PathMetadata
dist_name = basename(f)
if isdir(f):
path_item = dirname(f)
metadata = PathMetadata(path_item, f)
else:
path_item = f
metadata = FileMetadata(f)
dist = Distribution.from_location(path_item, dist_name, metadata)
And then for pulling the name for Provides, it uses dist.key and
Requires is iterating over dist.requires() to get the desired info.
Do I need to actually check the path and force it to use one
particular class over the other?
--
真実はいつも一つ!/ Always, there's only one truth!