How to use the auditwheel.patcher.Patchelf 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_elfpatcher.py View on Github external
def test_patchelf_check_output_fail(check_output):
    check_output.side_effect = CalledProcessError(1, "patchelf --version")
    with pytest.raises(ValueError, match="Could not call"):
        Patchelf()
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_set_soname(self, check_call, _0, _1):
        patcher = Patchelf()
        filename = "test.so"
        soname_new = "TEST_NEW"
        patcher.set_soname(filename, soname_new)
        check_call.assert_called_once_with(['patchelf', '--set-soname',
                                            soname_new, filename])
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_set_rpath(self, check_call, _0, _1):
        patcher = Patchelf()
        patcher.set_rpath("test.so", "$ORIGIN/.lib")
        check_call_expected_args = [call(['patchelf', '--remove-rpath',
                                          'test.so']),
                                    call(['patchelf', '--force-rpath',
                                          '--set-rpath', '$ORIGIN/.lib',
                                          'test.so'])]

        assert check_call.call_args_list == check_call_expected_args
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_get_rpath(self, _0, check_output, _1):
        patcher = Patchelf()
        check_output.return_value = b"existing_rpath"
        result = patcher.get_rpath("test.so")
        check_output_expected_args = [call(['patchelf', '--print-rpath',
                                            'test.so'])]

        assert result == check_output.return_value.decode()
        assert check_output.call_args_list == check_output_expected_args
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_patchelf_version_check(check_output, version):
    check_output.return_value.decode.return_value = "patchelf {}".format(version)
    Patchelf()
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_replace_needed(self, check_call, _0, _1):
        patcher = Patchelf()
        filename = "test.so"
        soname_old = "TEST_OLD"
        soname_new = "TEST_NEW"
        patcher.replace_needed(filename, soname_old, soname_new)
        check_call.assert_called_once_with(['patchelf', '--replace-needed',
                                            soname_old, soname_new, filename])
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_patchelf_unavailable(find_executable):
    find_executable.return_value = False
    with pytest.raises(ValueError):
        Patchelf()
github pypa / auditwheel / tests / unit / test_elfpatcher.py View on Github external
def test_patchelf_version_check_fail(check_output, version):
    check_output.return_value.decode.return_value = "patchelf {}".format(version)
    with pytest.raises(ValueError, match="patchelf {} found".format(version)):
        Patchelf()
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
if reqd_tag > get_priority_by_name(wheel_abi.sym_tag):
        msg = ('cannot repair "%s" to "%s" ABI because of the presence '
               'of too-recent versioned symbols. You\'ll need to compile '
               'the wheel on an older toolchain.' %
               (args.WHEEL_FILE, args.PLAT))
        p.error(msg)

    if reqd_tag > get_priority_by_name(wheel_abi.ucs_tag):
        msg = ('cannot repair "%s" to "%s" ABI because it was compiled '
               'against a UCS2 build of Python. You\'ll need to compile '
               'the wheel against a wide-unicode build of Python.' %
               (args.WHEEL_FILE, args.PLAT))
        p.error(msg)

    patcher = Patchelf()
    out_wheel = repair_wheel(args.WHEEL_FILE,
                             abi=args.PLAT,
                             lib_sdir=args.LIB_SDIR,
                             out_dir=args.WHEEL_DIR,
                             update_tags=args.UPDATE_TAGS,
                             patcher=patcher)

    if out_wheel is not None:
        analyzed_tag = analyze_wheel_abi(out_wheel).overall_tag
        if reqd_tag < get_priority_by_name(analyzed_tag):
            logger.info(('Wheel is eligible for a higher priority tag. '
                         'You requested %s but I have found this wheel is '
                         'eligible for %s.'),
                        args.PLAT, analyzed_tag)
            out_wheel = repair_wheel(args.WHEEL_FILE,
                                     abi=analyzed_tag,