@@ -21,22 +21,32 @@ def find_extra_reqs(options, requirements_filename):
21
21
installed_files = {}
22
22
all_pkgs = (pkg .project_name for pkg in get_installed_distributions ())
23
23
for package in search_packages_info (all_pkgs ):
24
- log .debug ('installed package: %s (at %s)' , package ['name' ],
25
- package ['location' ])
26
- for package_file in package .get ('files' , []) or []:
24
+ if isinstance (package , dict ):
25
+ package_name = package ['name' ]
26
+ package_location = package ['location' ]
27
+ package_files = package .get ('files' , []) or []
28
+ else :
29
+ package_name = package .name
30
+ package_location = package .location
31
+ package_files = package .files or []
32
+
33
+ log .debug ('installed package: %s (at %s)' , package_name ,
34
+ package_location )
35
+ for package_file in package_files :
27
36
path = os .path .realpath (
28
- os .path .join (package [ 'location' ] , package_file ),
37
+ os .path .join (package_location , package_file ),
29
38
)
30
- installed_files [path ] = package [ 'name' ]
39
+ installed_files [path ] = package_name
31
40
package_path = common .is_package_file (path )
32
41
if package_path :
33
42
# we've seen a package file so add the bare package directory
34
43
# to the installed list as well as we might want to look up
35
44
# a package by its directory path later
36
- installed_files [package_path ] = package [ 'name' ]
45
+ installed_files [package_path ] = package_name
37
46
38
47
# 3. match imported modules against those packages
39
48
used = collections .defaultdict (list )
49
+
40
50
for modname , info in used_modules .items ():
41
51
# probably standard library if it's not in the files list
42
52
if info .filename in installed_files :
0 commit comments