How to use the auditwheel.policy.get_priority_by_name 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_policy.py View on Github external
def test_get_by_name(self):
        _arch = get_arch_name()
        assert get_priority_by_name("manylinux2014_{}".format(_arch)) == 80
        if _arch in {'x86_64', 'i686'}:
            assert get_priority_by_name("manylinux2010_{}".format(_arch)) == 90
            assert get_priority_by_name("manylinux1_{}".format(_arch)) == 100
github eclipse / xacc / tools / wheels / fix_xacc_rpaths.py View on Github external
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,
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
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 '
               '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
github eclipse / xacc / tools / wheels / fix_xacc_rpaths.py View on Github external
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,
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
'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_show.py View on Github external
'need to recompile a new wheel from source on a system '
                'with earlier versions of these libraries, such as '
                'a recent manylinux image.') % winfo.sym_tag)
        if args.verbose < 1:
            return

    libs = winfo.external_refs[get_policy_name(POLICY_PRIORITY_LOWEST)]['libs']
    if len(libs) == 0:
        printp('The wheel requires no external shared libraries! :)')
    else:
        printp(('The following external shared libraries are required '
                'by the wheel:'))
        print(json.dumps(OrderedDict(sorted(libs.items())), indent=4))

    for p in sorted(load_policies(), key=lambda p: p['priority']):
        if p['priority'] > get_priority_by_name(winfo.overall_tag):
            printp(('In order to achieve the tag platform tag "%s" '
                    'the following shared library dependencies '
                    'will need to be eliminated:') % p['name'])
            printp(', '.join(
                sorted(winfo.external_refs[p['name']]['libs'].keys())))
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
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 '
               'the wheel against a wide-unicode build of Python.' %
               (args.WHEEL_FILE, args.PLAT))
        p.error(msg)

    patcher = Patchelf()
github pypa / auditwheel / auditwheel / main_show.py View on Github external
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

    if get_priority_by_name(winfo.ucs_tag) < POLICY_PRIORITY_HIGHEST:
        printp(('This wheel is compiled against a narrow unicode (UCS2) '
                'version of Python, which is not compatible with the '
                'manylinux1 tag.'))
        if args.verbose < 1:
            return

    if len(libs_with_versions) == 0:
        printp(("The wheel references no external versioned symbols from "
                "system-provided shared libraries."))
    else:
        printp('The wheel references external versioned symbols in these '
               'system-provided shared libraries: %s' %
               ', '.join(libs_with_versions))

    if get_priority_by_name(winfo.sym_tag) < POLICY_PRIORITY_HIGHEST:
        printp(('This constrains the platform tag to "%s". '
github pypa / auditwheel / auditwheel / main_repair.py View on Github external
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 '
               '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,