Skip to content

Commit

Permalink
Merge pull request #84 from anntzer/nonrecursive-get_req_external
Browse files Browse the repository at this point in the history
Nonrecursive get_req_external.
  • Loading branch information
ehashman authored Nov 8, 2017
2 parents 41135cf + e27ecfa commit ffdd71a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions auditwheel/policy/external_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import json
import logging
from functools import reduce
from typing import Tuple, Dict, List, Set, Any

from elftools.elf.elffile import ELFFile # type: ignore
Expand Down Expand Up @@ -33,10 +32,16 @@ def filter_libs(libs, whitelist):
yield lib

def get_req_external(libs: Set[str], whitelist: Set[str]):
# recurisvely get all the required external libraries
return reduce(set.union, (get_req_external(
set(filter_libs(lddtree['libs'][lib]['needed'], whitelist)),
whitelist) for lib in libs), libs)
# get all the required external libraries
libs = libs.copy()
reqs = set()
while libs:
lib = libs.pop()
reqs.add(lib)
for dep in filter_libs(lddtree['libs'][lib]['needed'], whitelist):
if dep not in reqs:
libs.add(dep)
return reqs

ret = {} # type: Dict[str, Dict[str, Any]]
for p in policies:
Expand Down

0 comments on commit ffdd71a

Please sign in to comment.