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
"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))
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())))
symbol_policies = get_symbol_policies(versioned_symbols,
external_versioned_symbols,
external_refs)
symbol_policy = versioned_symbols_policy(versioned_symbols)
# 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,
symbol_policy = versioned_symbols_policy(versioned_symbols)
# 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,
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)