How to use the auditwheel.elfutils.elf_read_dt_needed 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_missing_section(self, elffile_mock, open_mock):
        # GIVEN
        open_mock.return_value.__enter__.return_value = Mock()
        elffile_mock.return_value.get_section_by_name.return_value = None

        # THEN
        with pytest.raises(ValueError):
            # WHEN
            elf_read_dt_needed("/fake.so")
github pypa / auditwheel / tests / unit / test_elfutils.py View on Github external
def test_needed_libs(self, elffile_mock, open_mock):
        # GIVEN
        open_mock.return_value.__enter__.return_value = Mock()
        section_mock = Mock()
        tag1 = Mock(needed="libz.so")
        tag1.entry.d_tag = "DT_NEEDED"
        tag2 = Mock(needed="libfoo.so")
        tag2.entry.d_tag = "DT_NEEDED"
        section_mock.iter_tags.return_value = [tag1, tag2]
        elffile_mock.return_value.get_section_by_name.return_value = section_mock

        # WHEN
        needed = elf_read_dt_needed("/fake.so")

        # THEN
        assert len(needed) == 2
        assert "libz.so" in needed
        assert "libfoo.so" in needed
github eclipse / xacc / tools / wheels / fix_xacc_rpaths.py View on Github external
'library "%s" could not be located') %
                                     soname)

                new_soname, new_path = copylib(src_path, dest_dir)
                soname_map[soname] = (new_soname, new_path)
                check_call(['patchelf', '--replace-needed', soname, new_soname, fn])

            if len(ext_libs) > 0:
                patchelf_set_rpath(fn, dest_dir)

        # we grafted in a bunch of libraries and modifed their sonames, but
        # they may have internal dependencies (DT_NEEDED) on one another, so
        # we need to update those records so each now knows about the new
        # name of the other.
        for old_soname, (new_soname, path) in soname_map.items():
            needed = elf_read_dt_needed(path)
            for n in needed:
                if n in soname_map:
                    check_call(['patchelf', '--replace-needed', n, soname_map[n][0], path])


        check_call(['patchelf', '--force-rpath', '--set-rpath', '$ORIGIN/.libs:$ORIGIN/lib', 'xacc/_pyxacc.so'])

        if update_tags:
            ctx.out_wheel = add_platforms(ctx, [abi],
                                          get_replace_platforms(abi))
    return ctx.out_wheel
github pypa / auditwheel / auditwheel / repair.py View on Github external
new_soname, new_path = copylib(src_path, dest_dir, patcher)
                soname_map[soname] = (new_soname, new_path)
                patcher.replace_needed(fn, soname, new_soname)

            if len(ext_libs) > 0:
                new_rpath = os.path.relpath(dest_dir, os.path.dirname(fn))
                new_rpath = os.path.join('$ORIGIN', new_rpath)
                append_rpath_within_wheel(fn, new_rpath, ctx.name, patcher)

        # we grafted in a bunch of libraries and modified their sonames, but
        # they may have internal dependencies (DT_NEEDED) on one another, so
        # we need to update those records so each now knows about the new
        # name of the other.
        for old_soname, (new_soname, path) in soname_map.items():
            needed = elf_read_dt_needed(path)
            for n in needed:
                if n in soname_map:
                    patcher.replace_needed(path, n, soname_map[n][0])

        if update_tags:
            ctx.out_wheel = add_platforms(ctx, [abi],
                                          get_replace_platforms(abi))
    return ctx.out_wheel