aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/install.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-03-30 12:41:43 +0100
committerJason R. Coombs <jaraco@jaraco.com>2014-03-30 12:41:43 +0100
commit0b80f934c1e2effcc2484ae644613ad9beedf02f (patch)
tree12b4ea69b3600b83a8dbd020e2ea549accb29d78 /setuptools/command/install.py
parent58eb4b2b034d90f45b3daa12900f24a390bb4782 (diff)
downloadexternal_python_setuptools-0b80f934c1e2effcc2484ae644613ad9beedf02f.tar.gz
external_python_setuptools-0b80f934c1e2effcc2484ae644613ad9beedf02f.tar.bz2
external_python_setuptools-0b80f934c1e2effcc2484ae644613ad9beedf02f.zip
Extract a method to capture the intention of caller detection.
Diffstat (limited to 'setuptools/command/install.py')
-rw-r--r--setuptools/command/install.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/setuptools/command/install.py b/setuptools/command/install.py
index 784e8efd..c3f1ff92 100644
--- a/setuptools/command/install.py
+++ b/setuptools/command/install.py
@@ -52,19 +52,8 @@ class install(_install):
if self.old_and_unmanageable or self.single_version_externally_managed:
return _install.run(self)
- # Attempt to detect whether we were called from setup() or by another
- # command. If we were called by setup(), our caller will be the
- # 'run_command' method in 'distutils.dist', and *its* caller will be
- # the 'run_commands' method. If we were called any other way, our
- # immediate caller *might* be 'run_command', but it won't have been
- # called by 'run_commands'. This is slightly kludgy, but seems to
- # work.
- #
- caller = sys._getframe(2)
- caller_module = caller.f_globals.get('__name__','')
- caller_name = caller.f_code.co_name
-
- if caller_module != 'distutils.dist' or caller_name!='run_commands':
+ called_from_setup = self._called_from_setup(sys._getframe(2))
+ if not called_from_setup:
# We weren't called from the command line or setup(), so we
# should run in backward-compatibility mode to support bdist_*
# commands.
@@ -72,6 +61,25 @@ class install(_install):
else:
self.do_egg_install()
+ @staticmethod
+ def _called_from_setup(run_parent_parent):
+ """
+ Attempt to detect whether we were called from setup() or by another
+ command. If we were called by setup(), our caller will be the
+ 'run_command' method in 'distutils.dist', and *its* caller will be
+ the 'run_commands' method. If we were called any other way, our
+ immediate caller *might* be 'run_command', but it won't have been
+ called by 'run_commands'. This is slightly kludgy, but seems to
+ work.
+ """
+ caller = run_parent_parent
+ caller_module = caller.f_globals.get('__name__','')
+ caller_name = caller.f_code.co_name
+ return (
+ caller_module == 'distutils.dist'
+ and caller_name == 'run_commands'
+ )
+
def do_egg_install(self):
easy_install = self.distribution.get_command_class('easy_install')