示例#1
0
 def test_get_by_name(self):
     _arch = get_arch_name()
     assert get_priority_by_name(f"manylinux_2_24_{_arch}") == 70
     assert get_priority_by_name(f"manylinux2014_{_arch}") == 80
     if _arch in {'x86_64', 'i686'}:
         assert get_priority_by_name(f"manylinux2010_{_arch}") == 90
         assert get_priority_by_name(f"manylinux1_{_arch}") == 100
示例#2
0
 def test_get_by_name(self):
     _arch = get_arch_name()
     assert get_priority_by_name(f"manylinux_2_27_{_arch}") == 65
     assert get_priority_by_name(f"manylinux_2_24_{_arch}") == 70
     assert get_priority_by_name(f"manylinux2014_{_arch}") == 80
     assert get_priority_by_name(f"manylinux_2_17_{_arch}") == 80
     if _arch in {"x86_64", "i686"}:
         assert get_priority_by_name(f"manylinux2010_{_arch}") == 90
         assert get_priority_by_name(f"manylinux_2_12_{_arch}") == 90
         assert get_priority_by_name(f"manylinux1_{_arch}") == 100
         assert get_priority_by_name(f"manylinux_2_5_{_arch}") == 100
示例#3
0
def execute(args, p):
    import os
    from distutils.spawn import find_executable
    from auditwheel.wheel_abi import analyze_wheel_abi

    if not isfile(args.WHEEL_FILE):
        p.error('cannot access %s. No such file' % args.WHEEL_FILE)
    if find_executable('patchelf') is None:
        p.error('cannot find the \'patchelf\' tool, which is required')

    print('Repairing %s' % basename(args.WHEEL_FILE))

    if not exists(args.WHEEL_DIR):
        os.makedirs(args.WHEEL_DIR)

    wheel_abi = analyze_wheel_abi(args.WHEEL_FILE)
    reqd_tag = get_priority_by_name(args.PLAT)

    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)

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

    if out_wheel is not None:
        print('\nFixed-up wheel written to %s' % out_wheel)
示例#4
0
def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_container, docker_python,
                                             io_folder):
    # try to repair the wheel targeting different policies
    #
    # with_dependency == 0
    #   The python module has no dependencies that should be grafted-in and
    #   uses versioned symbols not available on policies pre-dating the policy
    #   matching the image being tested.
    # with_dependency == 1
    #   The python module itself does not use versioned symbols but has a
    #   dependency that should be grafted-in that uses versioned symbols not
    #   available on policies pre-dating the policy matching the image being
    #   tested.

    policy, tag, manylinux_ctr = any_manylinux_container

    docker_exec(manylinux_ctr, [
        'bash', '-c',
        'cd /auditwheel_src/tests/integration/testdependencies && '
        f'WITH_DEPENDENCY={with_dependency} python setup.py -v build_ext -f '
        'bdist_wheel -d /io'])

    filenames = os.listdir(io_folder)
    orig_wheel = filenames[0]
    assert 'manylinux' not in orig_wheel

    repair_command = \
        'LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testdependencies:$LD_LIBRARY_PATH '\
        'auditwheel -v repair --plat {policy} -w /io /io/{orig_wheel}'

    policy_priority = get_priority_by_name(policy)
    older_policies = \
        [f'{p}_{PLATFORM}' for p in MANYLINUX_IMAGES.keys()
         if policy_priority < get_priority_by_name(f'{p}_{PLATFORM}')]
    for target_policy in older_policies:
        # we shall fail to repair the wheel when targeting an older policy than
        # the one matching the image
        with pytest.raises(CalledProcessError):
            docker_exec(manylinux_ctr, [
                'bash',
                '-c',
                repair_command.format(policy=target_policy,
                                      orig_wheel=orig_wheel)])

    # check all works properly when targeting the policy matching the image
    docker_exec(manylinux_ctr, [
        'bash', '-c',
        repair_command.format(policy=policy, orig_wheel=orig_wheel)])
    filenames = os.listdir(io_folder)
    assert len(filenames) == 2
    repaired_wheel = f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl'
    assert repaired_wheel in filenames
    assert_show_output(manylinux_ctr, repaired_wheel, policy, True)

    # check the original wheel with a dependency was not compliant
    # and check the one without a dependency was already compliant
    if with_dependency == '1':
        expected = f'linux_{PLATFORM}'
    else:
        expected = policy
    assert_show_output(manylinux_ctr, orig_wheel, expected, True)

    docker_exec(docker_python, 'pip install /io/' + repaired_wheel)
    docker_exec(
        docker_python,
        ['python', '-c',
         'from sys import exit; from testdependencies import run; exit(run())']
    )
示例#5
0
def test_build_wheel_with_image_dependencies(with_dependency,
                                             any_manylinux_container,
                                             docker_python, io_folder):
    # try to repair the wheel targeting different policies
    #
    # with_dependency == 0
    #   The python module has no dependencies that should be grafted-in and
    #   uses versioned symbols not available on policies pre-dating the policy
    #   matching the image being tested.
    # with_dependency == 1
    #   The python module itself does not use versioned symbols but has a
    #   dependency that should be grafted-in that uses versioned symbols not
    #   available on policies pre-dating the policy matching the image being
    #   tested.

    policy, manylinux_ctr = any_manylinux_container

    docker_exec(manylinux_ctr, [
        'bash', '-c',
        'cd /auditwheel_src/tests/integration/testdependencies &&'
        'WITH_DEPENDENCY={} python setup.py -v build_ext -f bdist_wheel -d '
        '/io'.format(with_dependency)
    ])

    filenames = os.listdir(io_folder)
    orig_wheel = filenames[0]
    assert 'manylinux' not in orig_wheel

    repair_command = \
        'LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testdependencies:$LD_LIBRARY_PATH '\
        'auditwheel -v repair --plat {policy} -w /io /io/{orig_wheel}'

    policy_priority = get_priority_by_name(policy)
    older_policies = \
        [p for p in MANYLINUX_IMAGES.keys()
         if policy_priority < get_priority_by_name('{}_{}'.format(p, PLATFORM))]
    for target_policy in older_policies:
        # we shall fail to repair the wheel when targeting an older policy than
        # the one matching the image
        with pytest.raises(CalledProcessError):
            docker_exec(manylinux_ctr, [
                'bash', '-c',
                repair_command.format(policy=target_policy,
                                      orig_wheel=orig_wheel)
            ])

    # check all works properly when targeting the policy matching the image
    docker_exec(manylinux_ctr, [
        'bash', '-c',
        repair_command.format(policy=policy, orig_wheel=orig_wheel)
    ])
    filenames = os.listdir(io_folder)
    assert len(filenames) == 2
    repaired_wheels = [fn for fn in filenames if policy in fn]
    expected_wheel_name = \
        'testdependencies-0.0.1-{}-{}.whl'.format(PYTHON_ABI, policy)
    assert repaired_wheels == [expected_wheel_name]
    repaired_wheel = repaired_wheels[0]
    output = docker_exec(manylinux_ctr,
                         'auditwheel show /io/' + repaired_wheel)
    assert ('testdependencies-0.0.1-{abi}-{policy}.whl is consistent'
            ' with the following platform tag: "{policy}"').format(
                abi=PYTHON_ABI, policy=policy) in output.replace('\n', ' ')

    # check the original wheel with a dependency was not compliant
    # and check the one without a dependency was already compliant
    output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + orig_wheel)
    if with_dependency == '1':
        assert ('{orig_wheel} is consistent with the following platform tag: '
                '"linux_{platform}"').format(
                    orig_wheel=orig_wheel,
                    platform=PLATFORM) in output.replace('\n', ' ')
    else:
        assert ('{orig_wheel} is consistent with the following platform tag: '
                '"{policy}"').format(orig_wheel=orig_wheel,
                                     policy=policy) in output.replace(
                                         '\n', ' ')

    docker_exec(docker_python, 'pip install /io/' + repaired_wheel)
    docker_exec(docker_python, [
        'python', '-c',
        'from sys import exit; from testdependencies import run; exit(run())'
    ])
示例#6
0
 def test_get_by_name_duplicate(self):
     with pytest.raises(RuntimeError):
         get_priority_by_name("duplicate")
示例#7
0
 def test_get_by_name_missing(self):
     assert get_priority_by_name("nosuchpolicy") is None
示例#8
0
 def test_get_by_name(self):
     assert get_priority_by_name("manylinux1_x86_64") == 100