Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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")
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
'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
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