How to use the auditwheel.elfutils.elf_file_filter 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 / tests / unit / test_elfutils.py View on Github external
def test_not_elf(self, elffile_mock, open_mock):
        # GIVEN
        elffile_mock.side_effect = ELFError

        # WHEN
        result = elf_file_filter(["file1.notelf", "file2.notelf"])

        # THEN
        assert len(list(result)) == 0
github pypa / auditwheel / tests / unit / test_elfutils.py View on Github external
def test_some_py_files(self, elffile_mock, open_mock):
        result = elf_file_filter(["file1.py", "file2.so", "file3.py"])
        assert len(list(result)) == 1
github pypa / auditwheel / tests / unit / test_elfutils.py View on Github external
def test_filter(self, elffile_mock, open_mock):
        result = elf_file_filter(["file1.so", "file2.so"])
        assert len(list(result)) == 2
github pypa / auditwheel / auditwheel / wheel_abi.py View on Github external
def get_wheel_elfdata(wheel_fn: str):
    full_elftree = {}
    nonpy_elftree = {}
    full_external_refs = {}
    versioned_symbols = defaultdict(lambda: set())  # type: Dict[str, Set[str]]
    uses_ucs2_symbols = False
    uses_PyFPE_jbuf = False

    with InGenericPkgCtx(wheel_fn) as ctx:
        shared_libraries_in_purelib = []

        platform_wheel = False
        for fn, elf in elf_file_filter(ctx.iter_files()):
            platform_wheel = True

            # Check for invalid binary wheel format: no shared library should
            # be found in purelib
            so_path_split = fn.split(os.sep)

            # If this is in purelib, add it to the list of shared libraries in
            # purelib
            if 'purelib' in so_path_split:
                shared_libraries_in_purelib.append(so_path_split[-1])

            # If at least one shared library exists in purelib, this is going
            # to fail and there's no need to do further checks
            if not shared_libraries_in_purelib:
                log.debug('processing: %s', fn)
                elftree = lddtree(fn)
github pypa / auditwheel / auditwheel / wheel_abi.py View on Github external
def get_versioned_symbols(libs):
    """Get versioned symbols used in libraries
    :param libs: {realpath: soname} dict to search for versioned symbols e.g.
    {'/path/to/external_ref.so.1.2.3': 'external_ref.so.1'}
    :return: {soname: {depname: set([symbol_version])}} e.g.
    {'external_ref.so.1': {'libc.so.6', set(['GLIBC_2.5','GLIBC_2.12'])}}
    """
    result = {}
    for path, elf in elf_file_filter(libs.keys()):
        # {depname: set(symbol_version)}, e.g.
        # {'libc.so.6', set(['GLIBC_2.5','GLIBC_2.12'])}
        elf_versioned_symbols = defaultdict(lambda: set())
        for key, value in elf_find_versioned_symbols(elf):
            log.debug('path %s, key %s, value %s', path, key, value)
            elf_versioned_symbols[key].add(value)
        result[libs[path]] = elf_versioned_symbols
    return result