How to use the auditwheel.elfutils.is_subdir function in auditwheel

To help you get started, we’ve selected a few auditwheel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / auditwheel / auditwheel / repair.py View on Github external
def _is_valid_rpath(rpath: str,
                    lib_dir: str,
                    wheel_base_dir: str) -> bool:
    full_rpath_entry = _resolve_rpath_tokens(rpath, lib_dir)
    if not isabs(full_rpath_entry):
        logger.debug('rpath entry {} could not be resolved to an absolute '
                     'path -- discarding it.'.format(rpath))
        return False
    elif not is_subdir(full_rpath_entry, wheel_base_dir):
        logger.debug('rpath entry {} points outside the wheel -- discarding '
                     'it.'.format(rpath))
        return False
    else:
        logger.debug('Preserved rpath entry {}'.format(rpath))
        return True
github pypa / auditwheel / auditwheel / policy / external_references.py View on Github external
for p in policies:
        needed_external_libs = []  # type: List[str]

        if not (p['name'] == 'linux' and p['priority'] == 0):
            # special-case the generic linux platform here, because it
            # doesn't have a whitelist. or, you could say its
            # whitelist is the complete set of all libraries. so nothing
            # is considered "external" that needs to be copied in.
            whitelist = set(p['lib_whitelist'])
            needed_external_libs = get_req_external(
                set(filter_libs(lddtree['needed'], whitelist)),
                whitelist)

        pol_ext_deps = {}
        for lib in needed_external_libs:
            if is_subdir(lddtree['libs'][lib]['realpath'], wheel_path):
                # we didn't filter libs that resolved via RPATH out
                # earlier because we wanted to make sure to pick up
                # our elf's indirect dependencies. But now we want to
                # filter these ones out, since they're not "external".
                log.debug('RPATH FTW: %s', lib)
                continue
            pol_ext_deps[lib] = lddtree['libs'][lib]['realpath']
        ret[p['name']] = {'libs': pol_ext_deps, 'priority': p['priority']}
    return ret