How to use the auditwheel.wheel_abi.analyze_wheel_abi 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 / integration / test_bundled_pypy_snappy.py View on Github external
def test_analyze_wheel_abi_pypy_cffi():
    winfo = analyze_wheel_abi(
        'tests/integration/python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl')
    external_libs = winfo.external_refs['manylinux1_x86_64']['libs']
    assert len(external_libs) > 0
    assert set(external_libs) == {'libsnappy.so.1'}
github pypa / auditwheel / tests / integration / test_bundled_cffi.py View on Github external
def test_analyze_wheel_abi():
    winfo = analyze_wheel_abi('tests/integration/cffi-1.5.0-cp27-none-linux_x86_64.whl')
    external_libs = winfo.external_refs['manylinux1_x86_64']['libs']
    assert len(external_libs) > 0
    assert set(external_libs) == {'libffi.so.5'}
github pypa / auditwheel / tests / integration / test_pyfpe.py View on Github external
def test_analyze_wheel_abi():
    winfo = analyze_wheel_abi('tests/integration/fpewheel-0.0.0-cp35-cp35m-linux_x86_64.whl')
    assert winfo.sym_tag == 'manylinux1_x86_64'  # for external symbols, it could get manylinux1
    assert winfo.pyfpe_tag == 'linux_x86_64'     # but for having the pyfpe reference, it gets just linux
github pypa / auditwheel / auditwheel / main_addtag.py View on Github external
def execute(args, p):
    import os
    from wheel.wheelfile import WHEEL_INFO_RE  # type: ignore
    from .wheeltools import InWheelCtx, add_platforms, WheelToolsError
    from .wheel_abi import analyze_wheel_abi

    wheel_abi = analyze_wheel_abi(args.WHEEL_FILE)

    parsed_fname = WHEEL_INFO_RE.search(basename(args.WHEEL_FILE))
    in_fname_tags = parsed_fname.groupdict()['plat'].split('.')

    logger.info('%s receives the following tag: "%s".',
                basename(args.WHEEL_FILE), wheel_abi.overall_tag)
    logger.info('Use ``auditwheel show`` for more details')

    if wheel_abi.overall_tag in in_fname_tags:
        logger.info('No tags to be added. Exiting.')
        return 1

    # todo: move more of this logic to separate file
    if not exists(args.WHEEL_DIR):
        os.makedirs(args.WHEEL_DIR)
github pypa / auditwheel / auditwheel / main_show.py View on Github external
def execute(args, p):
    import json
    from os.path import isfile, basename
    from .policy import (load_policies, get_priority_by_name,
                         POLICY_PRIORITY_LOWEST, POLICY_PRIORITY_HIGHEST,
                         get_policy_name)
    from .wheel_abi import analyze_wheel_abi, NonPlatformWheel
    fn = basename(args.WHEEL_FILE)

    if not isfile(args.WHEEL_FILE):
        p.error('cannot access %s. No such file' % args.WHEEL_FILE)

    try:
        winfo = analyze_wheel_abi(args.WHEEL_FILE)
    except NonPlatformWheel:
        logger.info('This does not look like a platform wheel')
        return 1

    libs_with_versions = ['%s with versions %s' % (k, v)
                          for k, v in winfo.versioned_symbols.items()]

    printp('%s is consistent with the following platform tag: "%s".' %
           (fn, winfo.overall_tag))

    if get_priority_by_name(winfo.pyfpe_tag) < POLICY_PRIORITY_HIGHEST:
        printp(('This wheel uses the PyFPE_jbuf function, which is not '
                'compatible with the manylinux1 tag. (see '
                'https://www.python.org/dev/peps/pep-0513/#fpectl-builds-vs-no-fpectl-builds)'))  # noqa
        if args.verbose < 1:
            return
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
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,
                                     lib_sdir=args.LIB_SDIR,
                                     out_dir=args.WHEEL_DIR,
                                     update_tags=args.UPDATE_TAGS,
                                     patcher=patcher)

        logger.info('\nFixed-up wheel written to %s', out_wheel)
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
def execute(args, p):
    import os
    from .repair import repair_wheel
    from .wheel_abi import analyze_wheel_abi, NonPlatformWheel

    if not isfile(args.WHEEL_FILE):
        p.error('cannot access %s. No such file' % args.WHEEL_FILE)

    logger.info('Repairing %s', basename(args.WHEEL_FILE))

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

    try:
        wheel_abi = analyze_wheel_abi(args.WHEEL_FILE)
    except NonPlatformWheel:
        logger.info('This does not look like a platform wheel')
        return 1

    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 '
github eclipse / xacc / tools / wheels / fix_xacc_rpaths.py View on Github external
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)