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_policy_checks_glibc():
policy = versioned_symbols_policy({"some_library.so": {"GLIBC_2.5"}})
assert policy > POLICY_PRIORITY_LOWEST
policy = versioned_symbols_policy({"some_library.so": {"GLIBC_999"}})
assert policy == POLICY_PRIORITY_LOWEST
policy = versioned_symbols_policy({"some_library.so": {"OPENSSL_1_1_0"}})
assert policy == POLICY_PRIORITY_HIGHEST
policy = versioned_symbols_policy({"some_library.so": {"IAMALIBRARY"}})
assert policy == POLICY_PRIORITY_HIGHEST
def configure_parser(sub_parsers):
policy_names = [p['name'] for p in load_policies()]
highest_policy = get_policy_name(POLICY_PRIORITY_HIGHEST)
help = "Vendor in external shared library dependencies of a wheel."
p = sub_parsers.add_parser('repair', help=help, description=help)
p.add_argument('WHEEL_FILE', help='Path to wheel file.')
p.add_argument(
'--plat',
action=EnvironmentDefault,
env='AUDITWHEEL_PLAT',
dest='PLAT',
help='Desired target platform. (default: "%s")' % highest_policy,
choices=policy_names,
default=highest_policy)
p.add_argument('-L',
'--lib-sdir',
dest='LIB_SDIR',
help=('Subdirectory in packages to store copied libraries.'
' (default: ".libs")'),
def configure_parser(sub_parsers):
policy_names = [p['name'] for p in load_policies()]
highest_policy = get_policy_name(POLICY_PRIORITY_HIGHEST)
help = "Vendor in external shared library dependencies of a wheel."
p = sub_parsers.add_parser('repair', help=help, description=help)
p.add_argument('WHEEL_FILE', help='Path to wheel file.')
p.add_argument('-f',
'--force',
help='Override symbol version ABI check',
action='store_true')
p.add_argument(
'--plat',
dest='PLAT',
help='Desired target platform. (default: "%s")' % highest_policy,
choices=policy_names,
default=highest_policy)
p.add_argument('-L',
'--lib-sdir',
dest='LIB_SDIR',
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". '
'In order to achieve a more compatible tag, you would '
'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))
# let's keep the highest priority policy and
# corresponding versioned_symbols
symbol_policy, versioned_symbols = max(
symbol_policies,
key=lambda x: x[0],
default=(symbol_policy, versioned_symbols)
)
ref_policy = max(
(e['priority'] for e in external_refs.values() if len(e['libs']) == 0),
default=POLICY_PRIORITY_LOWEST)
if has_ucs2:
ucs_policy = POLICY_PRIORITY_LOWEST
else:
ucs_policy = POLICY_PRIORITY_HIGHEST
if uses_PyFPE_jbuf:
pyfpe_policy = POLICY_PRIORITY_LOWEST
else:
pyfpe_policy = POLICY_PRIORITY_HIGHEST
ref_tag = get_policy_name(ref_policy)
sym_tag = get_policy_name(symbol_policy)
ucs_tag = get_policy_name(ucs_policy)
pyfpe_tag = get_policy_name(pyfpe_policy)
overall_tag = get_policy_name(min(symbol_policy, ref_policy, ucs_policy,
pyfpe_policy))
return WheelAbIInfo(overall_tag, external_refs, ref_tag, versioned_symbols,
sym_tag, ucs_tag, pyfpe_tag)
default=(symbol_policy, versioned_symbols)
)
ref_policy = max(
(e['priority'] for e in external_refs.values() if len(e['libs']) == 0),
default=POLICY_PRIORITY_LOWEST)
if has_ucs2:
ucs_policy = POLICY_PRIORITY_LOWEST
else:
ucs_policy = POLICY_PRIORITY_HIGHEST
if uses_PyFPE_jbuf:
pyfpe_policy = POLICY_PRIORITY_LOWEST
else:
pyfpe_policy = POLICY_PRIORITY_HIGHEST
ref_tag = get_policy_name(ref_policy)
sym_tag = get_policy_name(symbol_policy)
ucs_tag = get_policy_name(ucs_policy)
pyfpe_tag = get_policy_name(pyfpe_policy)
overall_tag = get_policy_name(min(symbol_policy, ref_policy, ucs_policy,
pyfpe_policy))
return WheelAbIInfo(overall_tag, external_refs, ref_tag, versioned_symbols,
sym_tag, ucs_tag, pyfpe_tag)