code: def run_command_hooks(cmd_obj, hook_kind):
      
  
      hooks = getattr(cmd_obj, hook_kind, None)
  
      if not hooks:
          return
  
      for modname, hook in hooks:
          if isinstance(hook, str):
              try:
                  hook_obj = resolve_name(hook)
              except ImportError as exc:
                  raise DistutilsModuleError(
                      'cannot find hook {0}: {1}'.format(hook, exc))
          else:
              hook_obj = hook
  
          if not callable(hook_obj):
              raise DistutilsOptionError('hook {0!r} is not callable' % hook)
  
          log.info('running {0} from {1} for {2} command'.format(
                   hook_kind.rstrip('s'), modname, cmd_obj.get_command_name()))
  
          try:
              hook_obj(cmd_obj)
          except Exception:
              log.error('{0} command hook {1} raised an exception: %s\n'.format(
                  hook_obj.__name__, cmd_obj.get_command_name()))
              log.error(traceback.format_exc())
              sys.exit(1)
docs: Run hooks registered for that command and phase.
  
      *cmd_obj* is a finalized command object; *hook_kind* is either
      'pre_hook' or 'post_hook'.