code: def install_spark(dest, spark_version, hadoop_version, hive_version):
      """
      Installs Spark that corresponds to the given Hadoop version in the current
      library directory.
  
      Parameters
      ----------
      dest : str
          The location to download and install the Spark.
      spark_version : str
          Spark version. It should be spark-X.X.X form.
      hadoop_version : str
          Hadoop version. It should be hadoopX.X
          such as 'hadoop2.7' or 'without-hadoop'.
      hive_version : str
          Hive version. It should be hiveX.X such as 'hive2.3'.
      """
  
      package_name = checked_package_name(
          spark_version, hadoop_version, hive_version
      )
      package_local_path = os.path.join(dest, "%s.tgz" % package_name)
      if "PYSPARK_RELEASE_MIRROR" in os.environ:
          sites = [os.environ["PYSPARK_RELEASE_MIRROR"]]
      else:
          sites = get_preferred_mirrors()
      print(
          "Trying to download Spark %s from [%s]"
          % (spark_version, ", ".join(sites))
      )
  
      pretty_pkg_name = "%s for Hadoop %s" % (
          spark_version,
          "Free build"
          if hadoop_version == "without"
          else hadoop_version,
      )
  
      for site in sites:
          os.makedirs(dest, exist_ok=True)
          url = "%s/spark/%s/%s.tgz" % (
              site,
              spark_version,
              package_name,
          )
  
          tar = None
          try:
              print(
                  "Downloading %s from:\n- %s" % (pretty_pkg_name, url)
              )
              download_to_file(
                  urllib.request.urlopen(url), package_local_path
              )
  
              print("Installing to %s" % dest)
              tar = tarfile.open(package_local_path, "r:gz")
              for member in tar.getmembers():
                  if member.name == package_name:
                      # Skip the root directory.
                      continue
                  member.name = os.path.relpath(
                      member.name, package_name + os.path.sep
                  )
                  tar.extract(member, dest)
              return
          except Exception:
              print(
                  "Failed to download %s from %s:"
                  % (pretty_pkg_name, url)
              )
              traceback.print_exc()
              rmtree(dest, ignore_errors=True)
          finally:
              if tar is not None:
                  tar.close()
              if os.path.exists(package_local_path):
                  os.remove(package_local_path)
      raise IOError("Unable to download %s." % pretty_pkg_name)
  
file_path: spark/python/pyspark/install.py
imports: import os
  import re
  import tarfile
  import traceback
  import urllib.request
  from shutil import rmtree
label_desc: Use image node_id 4 for calling a global function with example usage: install_spark(dest, spark_version, hadoop_version, hive_version) without return types