コード例 #1
0
    def _called_from_setup(run_frame):
        """
        Attempt to detect whether run() was called from setup() or by another
        command.  If called by setup(), the parent caller will be the
        'run_command' method in 'distutils.dist', and *its* caller will be
        the 'run_commands' method.  If called any other way, the
        immediate caller *might* be 'run_command', but it won't have been
        called by 'run_commands'. Return True in that case or if a call stack
        is unavailable. Return False otherwise.
        """
        if run_frame is None:
            # If run_frame is None, just call the parent class logic
            return install._called_from_setup(run_frame)

        # Because Salt subclasses the setuptools install command, it needs to
        # override this static method to provide the right frame for the logic
        # so apply.

        # We first try the current run_frame in case the issue
        # https://github.com/pypa/setuptools/issues/456 is fixed.
        first_call = install._called_from_setup(run_frame)
        if first_call:
            return True

        # Fallback to providing the parent frame to have the right logic kick in
        second_call = install._called_from_setup(run_frame.f_back)
        if second_call is None:
            # There was no parent frame?!
            return first_call
        return second_call
コード例 #2
0
 def run(self):
     if not _install._called_from_setup(inspect.currentframe()):
         # The run function from setuptools.command.install doesn't detect
         # install cmd properly in the current setting of sub classing
         # Install and therefore we detect it here and do the right thing
         # for install command otherwise fall back to super class run for
         # the other cases.
         _install.run(self)
     else:
         _install.do_egg_install(self)
     self.execute(prepare_release, (self.install_lib, False),
                  msg='Preparing the installation')