コード例 #1
0
ファイル: pex.py プロジェクト: windie/heron
def _resolve_and_link_interpreter(requirement, fetchers, target_link,
                                  installer_provider):
    # 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

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

    with TRACER.timed('Interpreter cache resolving %s' % requirement, V=2):
        for link in links:
            with TRACER.timed('Fetching %s' % link, V=3):
                sdist = context.fetch(link)

            with TRACER.timed('Installing %s' % link, V=3):
                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)

            return EggPackage(target_location)
コード例 #2
0
ファイル: pex.py プロジェクト: Houzz/pex
def _resolve_and_link_interpreter(requirement, fetchers, target_link, installer_provider):
  # 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

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

  with TRACER.timed('Interpreter cache resolving %s' % requirement, V=2):
    for link in links:
      with TRACER.timed('Fetching %s' % link, V=3):
        sdist = context.fetch(link)

      with TRACER.timed('Installing %s' % link, V=3):
        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)

      return EggPackage(target_location)
コード例 #3
0
ファイル: resolver_options.py プロジェクト: jsirois/pex
 def __init__(self,
              fetchers=None,
              allow_external=False,
              allow_unverified=False,
              allow_prereleases=None,
              use_manylinux=None,
              precedence=None,
              context=None):
   self._fetchers = fetchers if fetchers is not None else [PyPIFetcher()]
   self._allow_external = allow_external
   self._allow_unverified = allow_unverified
   self._allow_prereleases = allow_prereleases
   self._use_manylinux = use_manylinux
   self._precedence = precedence if precedence is not None else Sorter.DEFAULT_PACKAGE_PRECEDENCE
   self._context = context or Context.get()
コード例 #4
0
 def __init__(self,
              fetchers=None,
              allow_external=False,
              allow_unverified=False,
              allow_prereleases=None,
              use_manylinux=None,
              precedence=None,
              context=None):
     self._fetchers = fetchers if fetchers is not None else [PyPIFetcher()]
     self._allow_external = allow_external
     self._allow_unverified = allow_unverified
     self._allow_prereleases = allow_prereleases
     self._use_manylinux = use_manylinux
     self._precedence = precedence if precedence is not None else Sorter.DEFAULT_PACKAGE_PRECEDENCE
     self._context = context or Context.get()
コード例 #5
0
 def get_network_context(self):
   # TODO(wickman): Add retry, conn_timeout, threads, etc configuration here.
   return Context.get()
コード例 #6
0
def context_from_config(config):
    # TODO(wickman) Add retry, conn_timeout, threads, etc configuration here.
    return Context.get()
コード例 #7
0
 def get_network_context(self):
   # TODO(wickman): Add retry, conn_timeout, threads, etc configuration here.
   return Context.get()
コード例 #8
0
ファイル: crawler.py プロジェクト: zuoxiaolei/pex
 def __init__(self, context=None, threads=1):
   self._threads = threads
   self.context = context or Context.get()