def InstallLibrary(name, version, explicit=True):
 (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)

def InstallLibrary ( name , version , explicit = True ) : ( 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 )
install a package .