code: def _install_grpcio_tools_and_generate_proto_files(force, output_dir):
      install_path = os.path.join(
          PYFLINK_ROOT_PATH, "..", ".eggs", "grpcio-wheels"
      )
      build_path = install_path + "-build"
      if os.path.exists(build_path):
          shutil.rmtree(build_path)
      logging.warning("Installing grpcio-tools into %s", install_path)
      try:
          start = time.time()
          # since '--prefix' option is only supported for pip 8.0+, so here we fallback to
          # use '--install-option' when the pip version is lower than 8.0.0.
          pip_version = pkg_resources.get_distribution("pip").version
          from pkg_resources import parse_version
  
          if parse_version(pip_version) >= parse_version("8.0.0"):
              subprocess.check_call(
                  [
                      sys.executable,
                      "-m",
                      "pip",
                      "install",
                      "--prefix",
                      install_path,
                      "--build",
                      build_path,
                      "--upgrade",
                      GRPC_TOOLS,
                      "-I",
                  ]
              )
          else:
              subprocess.check_call(
                  [
                      sys.executable,
                      "-m",
                      "pip",
                      "install",
                      "--install-option",
                      "--prefix=" + install_path,
                      "--build",
                      build_path,
                      "--upgrade",
                      GRPC_TOOLS,
                      "-I",
                  ]
              )
          from distutils.dist import Distribution
  
          install_obj = Distribution().get_command_obj(
              "install", create=True
          )
          install_obj.prefix = install_path
          install_obj.finalize_options()
          logging.warning(
              "Installing grpcio-tools took %0.2f seconds.",
              time.time() - start,
          )
      finally:
          sys.stderr.flush()
          shutil.rmtree(build_path, ignore_errors=True)
      sys.path.append(install_obj.install_purelib)
      pkg_resources.working_set.add_entry(install_obj.install_purelib)
      if install_obj.install_purelib != install_obj.install_platlib:
          sys.path.append(install_obj.install_platlib)
          pkg_resources.working_set.add_entry(
              install_obj.install_platlib
          )
      try:
          generate_proto_files(force, output_dir)
      finally:
          sys.stderr.flush()
  
file_path: flink/flink-python/pyflink/gen_protos.py
imports: from __future__ import absolute_import
  from __future__ import print_function
  import glob
  import logging
  import multiprocessing
  import os
  import platform
  import shutil
  import subprocess
  import sys
  import time
  import warnings
  import pkg_resources
label_desc: Use image node_id 2 for calling a global function with example usage: _install_grpcio_tools_and_generate_proto_files(force, output_dir) without return types