docs: def _get_system_python_executable():
      """ Returns the path the system-wide python binary.
          (In case we're running in a virtualenv or venv)
      """
      # This function is required by get_package_as_folder() to work
      # inside a virtualenv, since venv creation will fail with
      # the virtualenv's local python binary.
      # (venv/virtualenv incompatibility)
  
      # Abort if not in virtualenv or venv:
      if not hasattr(sys, "real_prefix") and (
              not hasattr(sys, "base_prefix") or
              os.path.normpath(sys.base_prefix) ==
              os.path.normpath(sys.prefix)):
          return sys.executable
  
      # Extract prefix we need to look in:
      if hasattr(sys, "real_prefix"):
          search_prefix = sys.real_prefix  # virtualenv
      else:
          search_prefix = sys.base_prefix  # venv
  
      def python_binary_from_folder(path):
          def binary_is_usable(python_bin):
              try:
                  filenotfounderror = FileNotFoundError
              except NameError:  # Python 2
                  filenotfounderror = OSError
              try:
                  subprocess.check_output([
                      os.path.join(path, python_bin), "--version"
                  ], stderr=subprocess.STDOUT)
                  return True
              except (subprocess.CalledProcessError, filenotfounderror):
                  return False
  
          python_name = "python" + sys.version
          while (not binary_is_usable(python_name) and
                 python_name.find(".") > 0):
              # Try less specific binary name:
              python_name = python_name.rpartition(".")[0]
          if binary_is_usable(python_name):
              return os.path.join(path, python_name)
          return None
  
      # Return from sys.real_prefix if present:
      result = python_binary_from_folder(search_prefix)
      if result is not None:
          return result
  
      # Check out all paths in $PATH:
      bad_candidates = []
      good_candidates = []
      ever_had_nonvenv_path = False
      for p in os.environ.get("PATH", "").split(":"):
          # Skip if not possibly the real system python:
          if not os.path.normpath(p).startswith(
                  os.path.normpath(search_prefix)
                  ):
              continue
  
          # First folders might be virtualenv/venv we want to avoid:
          if not ever_had_nonvenv_path:
              sep = os.path.sep
              if ("system32" not in p.lower() and "usr" not in p) or \
                      {"home", ".tox"}.intersection(set(p.split(sep))) or \
                      "users" in p.lower():
                  # Doesn't look like bog-standard system path.
                  if (p.endswith(os.path.sep + "bin") or
                          p.endswith(os.path.sep + "bin" + os.path.sep)):
                      # Also ends in "bin" -> likely virtualenv/venv.
                      # Add as unfavorable / end of candidates:
                      bad_candidates.append(p)
                      continue
              ever_had_nonvenv_path = True
  
          good_candidates.append(p)
  
      # See if we can now actually find the system python:
      for p in good_candidates + bad_candidates:
          result = python_binary_from_folder(p)
          if result is not None:
              return result
  
      raise RuntimeError("failed to locate system python in: " +
                         sys.real_prefix)