From 8a649ce9b96102be258e953bc5f0a8144a1423c4 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Wed, 24 Aug 2022 22:29:42 +0200 Subject: [PATCH 1/4] Improve log message in case of NonPlatformWheel error --- src/auditwheel/main_addtag.py | 5 ++++- src/auditwheel/main_repair.py | 5 ++++- src/auditwheel/main_show.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/auditwheel/main_addtag.py b/src/auditwheel/main_addtag.py index b23cf90b..7bda2adc 100644 --- a/src/auditwheel/main_addtag.py +++ b/src/auditwheel/main_addtag.py @@ -30,7 +30,10 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info("This does not look like a platform wheel") + logger.info( + "This does not look like a platform wheel" + ", no compiled extension file found in the wheel archive" + ) return 1 parsed_fname = WHEEL_INFO_RE.search(basename(args.WHEEL_FILE)) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index 1e0ae584..022cc754 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -116,7 +116,10 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(wheel_file) except NonPlatformWheel: - logger.info("This does not look like a platform wheel") + logger.info( + "This does not look like a platform wheel" + ", no compiled extension file found in the wheel archive" + ) return 1 policy = get_policy_by_name(args.PLAT) diff --git a/src/auditwheel/main_show.py b/src/auditwheel/main_show.py index 6bfdaae3..d94cab02 100644 --- a/src/auditwheel/main_show.py +++ b/src/auditwheel/main_show.py @@ -39,7 +39,10 @@ def execute(args, p): try: winfo = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info("This does not look like a platform wheel") + logger.info( + "This does not look like a platform wheel" + ", no compiled extension file found in the wheel archive" + ) return 1 libs_with_versions = [ From 574a702135b4feceadc8bb0880c737da71f18fe1 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sun, 9 Oct 2022 16:11:35 +0200 Subject: [PATCH 2/4] Improve message used in case of NonPlatformWheel --- pyproject.toml | 2 ++ src/auditwheel/main_addtag.py | 11 ++++++----- src/auditwheel/main_repair.py | 11 ++++++----- src/auditwheel/main_show.py | 11 ++++++----- src/auditwheel/wheel_abi.py | 7 +++++++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f7144866..d411e74c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,11 @@ build-backend = "setuptools.build_meta" [tool.black] target-version = ["py36", "py37", "py38", "py39"] +extend-exclude = "src/auditwheel/_vendor" [tool.isort] profile = "black" +extend_skip_glob = "src/auditwheel/_vendor/**/*.py" [tool.mypy] follow_imports = "silent" diff --git a/src/auditwheel/main_addtag.py b/src/auditwheel/main_addtag.py index 7bda2adc..e7b61b89 100644 --- a/src/auditwheel/main_addtag.py +++ b/src/auditwheel/main_addtag.py @@ -24,16 +24,17 @@ def execute(args, p): import os from ._vendor.wheel.wheelfile import WHEEL_INFO_RE - from .wheel_abi import NonPlatformWheel, analyze_wheel_abi + from .wheel_abi import ( + NOT_PLATFORM_WHEEL_MESSAGE, + NonPlatformWheel, + analyze_wheel_abi, + ) from .wheeltools import InWheelCtx, WheelToolsError, add_platforms try: wheel_abi = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info( - "This does not look like a platform wheel" - ", no compiled extension file found in the wheel archive" - ) + logger.info(NOT_PLATFORM_WHEEL_MESSAGE) return 1 parsed_fname = WHEEL_INFO_RE.search(basename(args.WHEEL_FILE)) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index 022cc754..a1aef5b8 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -102,7 +102,11 @@ def execute(args, p): import os from .repair import repair_wheel - from .wheel_abi import NonPlatformWheel, analyze_wheel_abi + from .wheel_abi import ( + NOT_PLATFORM_WHEEL_MESSAGE, + NonPlatformWheel, + analyze_wheel_abi, + ) for wheel_file in args.WHEEL_FILE: if not isfile(wheel_file): @@ -116,10 +120,7 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(wheel_file) except NonPlatformWheel: - logger.info( - "This does not look like a platform wheel" - ", no compiled extension file found in the wheel archive" - ) + logger.info(NOT_PLATFORM_WHEEL_MESSAGE) return 1 policy = get_policy_by_name(args.PLAT) diff --git a/src/auditwheel/main_show.py b/src/auditwheel/main_show.py index d94cab02..d7fd4614 100644 --- a/src/auditwheel/main_show.py +++ b/src/auditwheel/main_show.py @@ -29,7 +29,11 @@ def execute(args, p): get_priority_by_name, load_policies, ) - from .wheel_abi import NonPlatformWheel, analyze_wheel_abi + from .wheel_abi import ( + NOT_PLATFORM_WHEEL_MESSAGE, + NonPlatformWheel, + analyze_wheel_abi, + ) fn = basename(args.WHEEL_FILE) @@ -39,10 +43,7 @@ def execute(args, p): try: winfo = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info( - "This does not look like a platform wheel" - ", no compiled extension file found in the wheel archive" - ) + logger.info(NOT_PLATFORM_WHEEL_MESSAGE) return 1 libs_with_versions = [ diff --git a/src/auditwheel/wheel_abi.py b/src/auditwheel/wheel_abi.py index 467efd76..94837f96 100644 --- a/src/auditwheel/wheel_abi.py +++ b/src/auditwheel/wheel_abi.py @@ -51,6 +51,13 @@ class NonPlatformWheel(WheelAbiError): """No ELF binaries in the wheel""" +NOT_PLATFORM_WHEEL_MESSAGE = ( + "This does not look like a platform wheel, no ELF executable " + "or shared library file (including compiled Python C extension) " + "found in the wheel archive" +) + + @functools.lru_cache() def get_wheel_elfdata(wheel_fn: str): full_elftree = {} From bfd1ed7255cb112a4c335f3d144425e41983e4d6 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sun, 9 Oct 2022 16:27:51 +0200 Subject: [PATCH 3/4] Refactoring after review --- src/auditwheel/main_addtag.py | 8 ++------ src/auditwheel/main_repair.py | 8 ++------ src/auditwheel/main_show.py | 8 ++------ src/auditwheel/wheel_abi.py | 11 +++++------ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/auditwheel/main_addtag.py b/src/auditwheel/main_addtag.py index e7b61b89..f2e3bba6 100644 --- a/src/auditwheel/main_addtag.py +++ b/src/auditwheel/main_addtag.py @@ -24,17 +24,13 @@ def execute(args, p): import os from ._vendor.wheel.wheelfile import WHEEL_INFO_RE - from .wheel_abi import ( - NOT_PLATFORM_WHEEL_MESSAGE, - NonPlatformWheel, - analyze_wheel_abi, - ) + from .wheel_abi import NonPlatformWheel, analyze_wheel_abi from .wheeltools import InWheelCtx, WheelToolsError, add_platforms try: wheel_abi = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info(NOT_PLATFORM_WHEEL_MESSAGE) + logger.info(NonPlatformWheel.LogMessage) return 1 parsed_fname = WHEEL_INFO_RE.search(basename(args.WHEEL_FILE)) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index a1aef5b8..9e6eb164 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -102,11 +102,7 @@ def execute(args, p): import os from .repair import repair_wheel - from .wheel_abi import ( - NOT_PLATFORM_WHEEL_MESSAGE, - NonPlatformWheel, - analyze_wheel_abi, - ) + from .wheel_abi import NonPlatformWheel, analyze_wheel_abi for wheel_file in args.WHEEL_FILE: if not isfile(wheel_file): @@ -120,7 +116,7 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(wheel_file) except NonPlatformWheel: - logger.info(NOT_PLATFORM_WHEEL_MESSAGE) + logger.info(NonPlatformWheel.LogMessage) return 1 policy = get_policy_by_name(args.PLAT) diff --git a/src/auditwheel/main_show.py b/src/auditwheel/main_show.py index d7fd4614..9420d228 100644 --- a/src/auditwheel/main_show.py +++ b/src/auditwheel/main_show.py @@ -29,11 +29,7 @@ def execute(args, p): get_priority_by_name, load_policies, ) - from .wheel_abi import ( - NOT_PLATFORM_WHEEL_MESSAGE, - NonPlatformWheel, - analyze_wheel_abi, - ) + from .wheel_abi import NonPlatformWheel, analyze_wheel_abi fn = basename(args.WHEEL_FILE) @@ -43,7 +39,7 @@ def execute(args, p): try: winfo = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info(NOT_PLATFORM_WHEEL_MESSAGE) + logger.info(NonPlatformWheel.LogMessage) return 1 libs_with_versions = [ diff --git a/src/auditwheel/wheel_abi.py b/src/auditwheel/wheel_abi.py index 94837f96..988a585e 100644 --- a/src/auditwheel/wheel_abi.py +++ b/src/auditwheel/wheel_abi.py @@ -50,12 +50,11 @@ class WheelAbiError(Exception): class NonPlatformWheel(WheelAbiError): """No ELF binaries in the wheel""" - -NOT_PLATFORM_WHEEL_MESSAGE = ( - "This does not look like a platform wheel, no ELF executable " - "or shared library file (including compiled Python C extension) " - "found in the wheel archive" -) + LogMessage = ( + "This does not look like a platform wheel, no ELF executable " + "or shared library file (including compiled Python C extension) " + "found in the wheel archive" + ) @functools.lru_cache() From fc4c4a902f5e9a857b7caa73581b5dcc33737cbf Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sun, 9 Oct 2022 17:09:26 +0200 Subject: [PATCH 4/4] Refactoring after review --- src/auditwheel/main_addtag.py | 2 +- src/auditwheel/main_repair.py | 2 +- src/auditwheel/main_show.py | 2 +- src/auditwheel/wheel_abi.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auditwheel/main_addtag.py b/src/auditwheel/main_addtag.py index f2e3bba6..b77e1ef7 100644 --- a/src/auditwheel/main_addtag.py +++ b/src/auditwheel/main_addtag.py @@ -30,7 +30,7 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info(NonPlatformWheel.LogMessage) + logger.info(NonPlatformWheel.LOG_MESSAGE) return 1 parsed_fname = WHEEL_INFO_RE.search(basename(args.WHEEL_FILE)) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index 9e6eb164..b76f0b2f 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -116,7 +116,7 @@ def execute(args, p): try: wheel_abi = analyze_wheel_abi(wheel_file) except NonPlatformWheel: - logger.info(NonPlatformWheel.LogMessage) + logger.info(NonPlatformWheel.LOG_MESSAGE) return 1 policy = get_policy_by_name(args.PLAT) diff --git a/src/auditwheel/main_show.py b/src/auditwheel/main_show.py index 9420d228..a62835ec 100644 --- a/src/auditwheel/main_show.py +++ b/src/auditwheel/main_show.py @@ -39,7 +39,7 @@ def execute(args, p): try: winfo = analyze_wheel_abi(args.WHEEL_FILE) except NonPlatformWheel: - logger.info(NonPlatformWheel.LogMessage) + logger.info(NonPlatformWheel.LOG_MESSAGE) return 1 libs_with_versions = [ diff --git a/src/auditwheel/wheel_abi.py b/src/auditwheel/wheel_abi.py index 988a585e..de954795 100644 --- a/src/auditwheel/wheel_abi.py +++ b/src/auditwheel/wheel_abi.py @@ -50,7 +50,7 @@ class WheelAbiError(Exception): class NonPlatformWheel(WheelAbiError): """No ELF binaries in the wheel""" - LogMessage = ( + LOG_MESSAGE = ( "This does not look like a platform wheel, no ELF executable " "or shared library file (including compiled Python C extension) " "found in the wheel archive"