Skip to content

Commit a3d058f

Browse files
committed
Handle dist-info installed wheel directories
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 76855ff commit a3d058f

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

pkginfo/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ def get_metadata(path_or_module, metadata_version=None):
5151
pass
5252

5353
if os.path.isdir(path_or_module):
54+
try:
55+
return Wheel(path_or_module, metadata_version)
56+
except (ValueError, IOError): #pragma NO COVER
57+
pass
58+
5459
try:
5560
return Develop(path_or_module, metadata_version)
5661
except (ValueError, IOError): #pragma NO COVER
5762
pass
63+

pkginfo/wheel.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,19 @@ def read(self):
2626

2727
def read_file(name):
2828
return archive.read(name)
29+
30+
close = archive.close
31+
32+
elif fqn.endswith('.dist-info'):
33+
names = [os.path.join(fqn, p) for p in os.listdir(fqn)]
34+
35+
def read_file(name):
36+
return open(name).read()
37+
38+
close = lambda : 0
39+
2940
else:
30-
raise ValueError('Not a known archive format: %s' % fqn)
41+
raise ValueError('Not a known wheel archive format or installed .dist-info: %s' % fqn)
3142

3243
try:
3344
tuples = [x.split('/') for x in names if 'METADATA' in x]
@@ -38,7 +49,7 @@ def read_file(name):
3849
if b'Metadata-Version' in data:
3950
return data
4051
finally:
41-
archive.close()
52+
close()
4253

4354
raise ValueError('No METADATA in archive: %s' % fqn)
4455

0 commit comments

Comments
 (0)