From 93a24585683944a9369d8fd37a824c0bca345af4 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Mar 2022 22:48:21 +0000 Subject: Make install consider dist.run_command is overwritten in v61.0.0 Starting in v61, setuptools.dist overwrites distutils.dist.run_command to add auto-discovery functionality on top of the original implementation. This change modifies the existing code in setuptools.command.install to consider that previous change when trying to decide if the install command was called directly from `setup.py` or not. --- setuptools/command/install.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'setuptools/command/install.py') diff --git a/setuptools/command/install.py b/setuptools/command/install.py index 35e54d20..55fdb124 100644 --- a/setuptools/command/install.py +++ b/setuptools/command/install.py @@ -91,14 +91,21 @@ class install(orig.install): msg = "For best results, pass -X:Frames to enable call stack." warnings.warn(msg) return True - res = inspect.getouterframes(run_frame)[2] - caller, = res[:1] - info = inspect.getframeinfo(caller) - caller_module = caller.f_globals.get('__name__', '') - return ( - caller_module == 'distutils.dist' - and info.function == 'run_commands' - ) + + frames = inspect.getouterframes(run_frame) + for frame in frames[2:4]: + caller, = frame[:1] + info = inspect.getframeinfo(caller) + caller_module = caller.f_globals.get('__name__', '') + + if caller_module == "setuptools.dist" and info.function == "run_command": + # Starting from v61.0.0 setuptools overwrites dist.run_command + continue + + return ( + caller_module == 'distutils.dist' + and info.function == 'run_commands' + ) def do_egg_install(self): -- cgit v1.2.1