示例#1
0
def _resolve_and_link(config,
                      requirement,
                      target_link,
                      installer_provider,
                      logger=print):
    if os.path.exists(target_link) and os.path.exists(
            os.path.realpath(target_link)):
        egg = EggPackage(os.path.realpath(target_link))
        if egg.satisfies(requirement):
            return egg
    fetchers = fetchers_from_config(config)
    crawler = crawler_from_config(config)
    obtainer = Obtainer(crawler, fetchers, [])
    obtainer_iterator = obtainer.iter(requirement)
    links = [
        link for link in obtainer_iterator if isinstance(link, SourcePackage)
    ]
    for link in links:
        logger('    fetching %s' % link.url)
        sdist = link.fetch()
        logger('    installing %s' % sdist)
        installer = installer_provider(sdist)
        dist_location = installer.bdist()
        target_location = os.path.join(os.path.dirname(target_link),
                                       os.path.basename(dist_location))
        shutil.move(dist_location, target_location)
        _safe_link(target_location, target_link)
        logger('    installed %s' % target_location)
        return EggPackage(target_location)
示例#2
0
def _resolve_and_link(config,
                      requirement,
                      target_link,
                      installer_provider,
                      logger=print):
    # Short-circuit if there is a local copy
    if os.path.exists(target_link) and os.path.exists(
            os.path.realpath(target_link)):
        egg = EggPackage(os.path.realpath(target_link))
        if egg.satisfies(requirement):
            return egg

    fetchers = fetchers_from_config(config)
    context = context_from_config(config)
    iterator = Iterator(fetchers=fetchers, crawler=Crawler(context))
    links = [
        link for link in iterator.iter(requirement)
        if isinstance(link, SourcePackage)
    ]

    for link in links:
        logger('    fetching %s' % link.url)
        sdist = context.fetch(link)
        logger('    installing %s' % sdist)
        installer = installer_provider(sdist)
        dist_location = installer.bdist()
        target_location = os.path.join(os.path.dirname(target_link),
                                       os.path.basename(dist_location))
        shutil.move(dist_location, target_location)
        _safe_link(target_location, target_link)
        logger('    installed %s' % target_location)
        return EggPackage(target_location)
示例#3
0
def _resolve_and_link(config, requirement, target_link, installer_provider, logger=print):
  if os.path.exists(target_link) and os.path.exists(os.path.realpath(target_link)):
    egg = EggPackage(os.path.realpath(target_link))
    if egg.satisfies(requirement):
      return egg
  fetchers = fetchers_from_config(config)
  crawler = crawler_from_config(config)
  obtainer = Obtainer(crawler, fetchers, [])
  obtainer_iterator = obtainer.iter(requirement)
  links = [link for link in obtainer_iterator if isinstance(link, SourcePackage)]
  for link in links:
    logger('    fetching %s' % link.url)
    sdist = link.fetch()
    logger('    installing %s' % sdist)
    installer = installer_provider(sdist)
    dist_location = installer.bdist()
    target_location = os.path.join(os.path.dirname(target_link), os.path.basename(dist_location))
    shutil.move(dist_location, target_location)
    _safe_link(target_location, target_link)
    logger('    installed %s' % target_location)
    return EggPackage(target_location)
示例#4
0
def _resolve_and_link(config, requirement, target_link, installer_provider, logger=print):
  # Short-circuit if there is a local copy
  if os.path.exists(target_link) and os.path.exists(os.path.realpath(target_link)):
    egg = EggPackage(os.path.realpath(target_link))
    if egg.satisfies(requirement):
      return egg

  fetchers = fetchers_from_config(config)
  context = context_from_config(config)
  iterator = Iterator(fetchers=fetchers, crawler=Crawler(context))
  links = [link for link in iterator.iter(requirement) if isinstance(link, SourcePackage)]

  for link in links:
    logger('    fetching %s' % link.url)
    sdist = context.fetch(link)
    logger('    installing %s' % sdist)
    installer = installer_provider(sdist)
    dist_location = installer.bdist()
    target_location = os.path.join(os.path.dirname(target_link), os.path.basename(dist_location))
    shutil.move(dist_location, target_location)
    _safe_link(target_location, target_link)
    logger('    installed %s' % target_location)
    return EggPackage(target_location)