示例#1
0
    def distribution_from_path(cls, path, name=None):
        """Return a distribution from a path.

        If name is provided, find the distribution.  If none is found matching the name, return
        None.  If name is not provided and there is unambiguously a single distribution, return that
        distribution otherwise None.
        """
        if name is None:
            distributions = set(find_distributions(path))
            if len(distributions) == 1:
                return distributions.pop()
        else:
            for dist in find_distributions(path):
                if dist.project_name == name:
                    return dist
示例#2
0
 def all_distribution_paths(path):
     # type: (Optional[str]) -> Iterable[str]
     if path is None:
         return ()
     locations = set(dist.location for dist in find_distributions(path))
     return {path} | locations | set(
         os.path.realpath(path) for path in locations)
示例#3
0
文件: util.py 项目: zuoxiaolei/pex
    def distribution_from_path(cls, path, name=None):
        """Return a distribution from a path.

    If name is provided, find the distribution.  If none is found matching the name,
    return None.  If name is not provided and there is unambiguously a single
    distribution, return that distribution otherwise None.
    """
        # Monkeypatch pkg_resources finders should it not already be so.
        register_finders()
        if name is None:
            distributions = set(find_distributions(path))
            if len(distributions) == 1:
                return distributions.pop()
        else:
            for dist in find_distributions(path):
                if dist.project_name == name:
                    return dist
示例#4
0
文件: finders.py 项目: jsirois/pex
def find_wheels_on_path(importer, path_item, only=False):
  if not os.path.isdir(path_item) or not os.access(path_item, os.R_OK):
    return
  if not only:
    for entry in os.listdir(path_item):
      if entry.lower().endswith('.whl'):
        for dist in pkg_resources.find_distributions(os.path.join(path_item, entry)):
          yield dist
示例#5
0
文件: util.py 项目: jsirois/pex
  def distribution_from_path(cls, path, name=None):
    """Return a distribution from a path.

    If name is provided, find the distribution.  If none is found matching the name,
    return None.  If name is not provided and there is unambiguously a single
    distribution, return that distribution otherwise None.
    """
    # Monkeypatch pkg_resources finders should it not already be so.
    register_finders()
    if name is None:
      distributions = set(find_distributions(path))
      if len(distributions) == 1:
        return distributions.pop()
    else:
      for dist in find_distributions(path):
        if dist.project_name == name:
          return dist
示例#6
0
文件: finders.py 项目: zuoxiaolei/pex
def find_wheels_on_path(importer, path_item, only=False):
    if not os.path.isdir(path_item) or not os.access(path_item, os.R_OK):
        return
    if not only:
        for entry in os.listdir(path_item):
            if entry.lower().endswith('.whl'):
                for dist in pkg_resources.find_distributions(
                        os.path.join(path_item, entry)):
                    yield dist
示例#7
0
 def load_internal_cache(cls, pex, pex_info):
   """Possibly cache out the internal cache."""
   internal_cache = os.path.join(pex, pex_info.internal_cache)
   with TRACER.timed('Searching dependency cache: %s' % internal_cache, V=2):
     if os.path.isdir(pex):
       for dist in find_distributions(internal_cache):
         yield dist
     else:
       for dist in itertools.chain(*cls.write_zipped_internal_cache(pex, pex_info)):
         yield dist
示例#8
0
 def load_internal_cache(cls, pex, pex_info):
   """Possibly cache out the internal cache."""
   internal_cache = os.path.join(pex, pex_info.internal_cache)
   with TRACER.timed('Searching dependency cache: %s' % internal_cache, V=2):
     if os.path.isdir(pex):
       for dist in find_distributions(internal_cache):
         yield dist
     else:
       for dist in itertools.chain(*cls.write_zipped_internal_cache(pex, pex_info)):
         yield dist
示例#9
0
    def scan_egg_link(self, path, entry):
        with open(os.path.join(path, entry)) as raw_lines:
            # filter non-empty lines
            lines = list(filter(None, map(str.strip, raw_lines)))

        if len(lines) != 2:
            # format is not recognized; punt
            return

        egg_path, setup_path = lines

        for dist in find_distributions(os.path.join(path, egg_path)):
            dist.location = os.path.join(path, *lines)
            dist.precedence = SOURCE_DIST
            self.add(dist)
示例#10
0
 def all_distribution_paths(path):
     locations = set(dist.location for dist in find_distributions(path))
     return set([path]) | locations | set(
         os.path.realpath(path) for path in locations)
示例#11
0
文件: pex.py 项目: jsirois/pex
 def all_distribution_paths(path):
   locations = set(dist.location for dist in find_distributions(path))
   return set([path]) | locations | set(os.path.realpath(path) for path in locations)