def InstallLibrary(name, version, explicit=True):
  """Install a package.

  If the installation is explicit then the user made the installation request,
  not a package as a dependency. Explicit installation leads to stricter
  version checking.

  Args:
    name: Name of the requested package (already validated as available).
    version: The desired version (already validated as available).
    explicit: Explicitly requested by the user or implicitly because of a
      dependency.
  """
  installed_version, explicitly_installed = installed.get(name, [None] * 2)





  if name in sys.modules:
    if explicit:
      CheckInstalledVersion(name, version, explicit=True)
    return

  elif installed_version:
    if version == installed_version:
      return


    if explicit:
      if explicitly_installed:
        raise ValueError('%s %s requested, but %s already in use' %
                         (name, version, installed_version))
      RemoveLibrary(name)


    else:
      version_ob = distutils.version.LooseVersion(version)
      installed_ob = distutils.version.LooseVersion(installed_version)
      if version_ob <= installed_ob:
        return
      else:
        RemoveLibrary(name)

  AddLibrary(name, version, explicit)
  dep_details = PACKAGES[name][1][version]
  if not dep_details:
    return
  for dep_name, dep_version in dep_details:
    InstallLibrary(dep_name, dep_version, explicit=False)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/dist/_library.py/InstallLibrary/original