From c08259d1b87daa9cd2b565152dc0da4773637076 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Tue, 21 Jun 2022 16:12:31 +0300 Subject: [PATCH 1/2] Add -vv TRACE logging level To reduce the output of policy checker unless requested --- src/auditwheel/main.py | 11 +++++++---- src/auditwheel/policy/versioned_symbols.py | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/auditwheel/main.py b/src/auditwheel/main.py index e276fcdb..6473005c 100644 --- a/src/auditwheel/main.py +++ b/src/auditwheel/main.py @@ -47,10 +47,13 @@ def main() -> Optional[int]: args = p.parse_args() logging.disable(logging.NOTSET) - if args.verbose >= 1: - logging.basicConfig(level=logging.DEBUG) - else: - logging.basicConfig(level=logging.INFO) + TRACE = 5 + logging.addLevelName(TRACE, "TRACE") + logging.basicConfig(level=logging.INFO) + if args.verbose == 1: + logging.getLogger().setLevel(logging.DEBUG) + elif args.verbose > 1: + logging.getLogger().setLevel(TRACE) if not hasattr(args, "func"): p.print_help() diff --git a/src/auditwheel/policy/versioned_symbols.py b/src/auditwheel/policy/versioned_symbols.py index db0c1abc..343109ef 100644 --- a/src/auditwheel/policy/versioned_symbols.py +++ b/src/auditwheel/policy/versioned_symbols.py @@ -4,6 +4,7 @@ from . import load_policies log = logging.getLogger(__name__) +TRACE = 5 def versioned_symbols_policy(versioned_symbols: Dict[str, Set[str]]) -> int: @@ -13,12 +14,14 @@ def policy_is_satisfied( policy_satisfied = True for name in set(required_vers) & set(policy_sym_vers): if not required_vers[name].issubset(policy_sym_vers[name]): + log.debug( + "Package requirements incompatible with policy %s", + policy_name) for symbol in required_vers[name] - policy_sym_vers[name]: - log.debug( - "Package requires %s, incompatible with " - "policy %s which requires %s", + log.log( + TRACE, + " %s is incompatible with %s", symbol, - policy_name, policy_sym_vers[name], ) policy_satisfied = False From fc0360c7de50bf47ce482c3b4c2783dee677df7b Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Tue, 21 Jun 2022 16:37:47 +0300 Subject: [PATCH 2/2] Load policies in the order they are defined To have some order in log messages --- src/auditwheel/policy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auditwheel/policy/__init__.py b/src/auditwheel/policy/__init__.py index 19ff9eb6..be608f7f 100644 --- a/src/auditwheel/policy/__init__.py +++ b/src/auditwheel/policy/__init__.py @@ -2,7 +2,7 @@ import logging import platform as _platform_module import sys -from collections import defaultdict +from collections import defaultdict, OrderedDict from os.path import abspath, dirname, join from pathlib import Path from typing import Dict, List, Optional, Set @@ -102,7 +102,7 @@ def _fixup_musl_libc_soname(whitelist): with _POLICY_JSON_MAP[_LIBC].open() as f: _POLICIES = [] - _policies_temp = json.load(f) + _policies_temp = json.load(f, object_pairs_hook=OrderedDict) _validate_pep600_compliance(_policies_temp) for _p in _policies_temp: if _MUSL_POLICY is not None and _p["name"] not in {"linux", _MUSL_POLICY}: