当前位置: 首页>>代码示例>>Python>>正文


Python pkg_resources.Distribution方法代码示例

本文整理汇总了Python中pip._vendor.pkg_resources.Distribution方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.Distribution方法的具体用法?Python pkg_resources.Distribution怎么用?Python pkg_resources.Distribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.pkg_resources的用法示例。


在下文中一共展示了pkg_resources.Distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _script_names

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def _script_names(dist, script_name, is_gui):
    # type: (Distribution, str, bool) -> List[str]
    """Create the fully qualified name of the files created by
    {console,gui}_scripts for the given ``dist``.
    Returns the list of file names
    """
    if dist_in_usersite(dist):
        bin_dir = bin_user
    else:
        bin_dir = bin_py
    exe_name = os.path.join(bin_dir, script_name)
    paths_to_remove = [exe_name]
    if WINDOWS:
        paths_to_remove.append(exe_name + '.exe')
        paths_to_remove.append(exe_name + '.exe.manifest')
        if is_gui:
            paths_to_remove.append(exe_name + '-script.pyw')
        else:
            paths_to_remove.append(exe_name + '-script.py')
    return paths_to_remove 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:22,代码来源:req_uninstall.py

示例2: uninstallation_paths

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def uninstallation_paths(dist):
    # type: (Distribution) -> Iterator[str]
    """
    Yield all the uninstallation paths for dist based on RECORD-without-.py[co]

    Yield paths to all the files in RECORD. For each .py file in RECORD, add
    the .pyc and .pyo in the same directory.

    UninstallPathSet.add() takes care of the __pycache__ .py[co].
    """
    r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
    for row in r:
        path = os.path.join(dist.location, row[0])
        yield path
        if path.endswith('.py'):
            dn, fn = os.path.split(path)
            base = fn[:-3]
            path = os.path.join(dn, base + '.pyc')
            yield path
            path = os.path.join(dn, base + '.pyo')
            yield path 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:23,代码来源:req_uninstall.py

示例3: get_dist

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def get_dist(self):
        # type: () -> Distribution
        """Return a pkg_resources.Distribution for this requirement"""
        if self.metadata_directory:
            base_dir, distinfo = os.path.split(self.metadata_directory)
            metadata = pkg_resources.PathMetadata(
                base_dir, self.metadata_directory
            )
            dist_name = os.path.splitext(distinfo)[0]
            typ = pkg_resources.DistInfoDistribution
        else:
            egg_info = self.egg_info_path.rstrip(os.path.sep)
            base_dir = os.path.dirname(egg_info)
            metadata = pkg_resources.PathMetadata(base_dir, egg_info)
            dist_name = os.path.splitext(os.path.basename(egg_info))[0]
            # https://github.com/python/mypy/issues/1174
            typ = pkg_resources.Distribution  # type: ignore

        return typ(
            base_dir,
            project_name=dist_name,
            metadata=metadata,
        ) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:25,代码来源:req_install.py

示例4: get_metadata

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def get_metadata(dist):
    # type: (Distribution) -> Message
    """
    :raises NoneMetadataError: if the distribution reports `has_metadata()`
        True but `get_metadata()` returns None.
    """
    metadata_name = 'METADATA'
    if (isinstance(dist, pkg_resources.DistInfoDistribution) and
            dist.has_metadata(metadata_name)):
        metadata = dist.get_metadata(metadata_name)
    elif dist.has_metadata('PKG-INFO'):
        metadata_name = 'PKG-INFO'
        metadata = dist.get_metadata(metadata_name)
    else:
        logger.warning("No metadata found in %s", display_path(dist.location))
        metadata = ''

    if metadata is None:
        raise NoneMetadataError(dist, metadata_name)

    feed_parser = FeedParser()
    # The following line errors out if with a "NoneType" TypeError if
    # passed metadata=None.
    feed_parser.feed(metadata)
    return feed_parser.close() 
开发者ID:pantsbuild,项目名称:pex,代码行数:27,代码来源:packaging.py

示例5: get_dist

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def get_dist(self):
        """Return a pkg_resources.Distribution built from self.egg_info_path"""
        egg_info = self.egg_info_path('').rstrip('/')
        base_dir = os.path.dirname(egg_info)
        metadata = pkg_resources.PathMetadata(base_dir, egg_info)
        dist_name = os.path.splitext(os.path.basename(egg_info))[0]
        return pkg_resources.Distribution(
            os.path.dirname(egg_info),
            project_name=dist_name,
            metadata=metadata) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:req_install.py

示例6: __getitem__

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def __getitem__(self, key: str) -> pkg_resources.Distribution:
        rv = self.env[key]
        if rv:
            return rv[0]
        else:
            raise KeyError(key) 
开发者ID:frostming,项目名称:pdm,代码行数:8,代码来源:environment.py

示例7: is_dist_editable

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def is_dist_editable(dist: Distribution) -> bool:
    return isinstance(dist, EggInfoDistribution) 
开发者ID:frostming,项目名称:pdm,代码行数:4,代码来源:installers.py

示例8: format_dist

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def format_dist(dist: Distribution) -> str:
    formatter = "{version}{path}"
    path = ""
    if is_dist_editable(dist):
        path = f" (-e {dist.location})"
    return formatter.format(version=stream.yellow(dist.version), path=path) 
开发者ID:frostming,项目名称:pdm,代码行数:8,代码来源:installers.py

示例9: uninstall

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def uninstall(self, dist: Distribution) -> None:
        req = parse_requirement(dist.project_name)
        if is_dist_editable(dist):
            ireq = shims.install_req_from_editable(dist.location)
        else:
            ireq = shims.install_req_from_line(dist.project_name)
        ireq.req = req

        with self.environment.activate():
            pathset = ireq.uninstall(auto_confirm=self.auto_confirm)
            if pathset:
                pathset.commit() 
开发者ID:frostming,项目名称:pdm,代码行数:14,代码来源:installers.py

示例10: update_candidate

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def update_candidate(self, key: str) -> Tuple[Distribution, Candidate]:
        """Update candidate"""
        can = self.candidates[key]
        dist = self.working_set[safe_name(can.name).lower()]
        installer = self.get_installer()
        installer.uninstall(dist)
        installer.install(can)
        return dist, can 
开发者ID:frostming,项目名称:pdm,代码行数:10,代码来源:synchronizers.py

示例11: get_dist

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def get_dist(self):
        """Return a pkg_resources.Distribution built from self.egg_info_path"""
        egg_info = self.egg_info_path('').rstrip(os.path.sep)
        base_dir = os.path.dirname(egg_info)
        metadata = pkg_resources.PathMetadata(base_dir, egg_info)
        dist_name = os.path.splitext(os.path.basename(egg_info))[0]
        return pkg_resources.Distribution(
            os.path.dirname(egg_info),
            project_name=dist_name,
            metadata=metadata,
        ) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:13,代码来源:req_install.py

示例12: dist

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def dist(self):
        # type: () -> pkg_resources.Distribution
        return list(pkg_resources.find_distributions(
            self.req.source_dir))[0] 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:6,代码来源:prepare.py

示例13: dist_is_local

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def dist_is_local(dist):
    # type: (Distribution) -> bool
    """
    Return True if given Distribution object is installed locally
    (i.e. within current virtualenv).

    Always True if we're not in a virtualenv.

    """
    return is_local(dist_location(dist)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:12,代码来源:misc.py

示例14: dist_in_usersite

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def dist_in_usersite(dist):
    # type: (Distribution) -> bool
    """
    Return True if given Distribution is installed in user site.
    """
    norm_path = normalize_path(dist_location(dist))
    return norm_path.startswith(normalize_path(user_site)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:9,代码来源:misc.py

示例15: dist_in_site_packages

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import Distribution [as 别名]
def dist_in_site_packages(dist):
    # type: (Distribution) -> bool
    """
    Return True if given Distribution is installed in
    sysconfig.get_python_lib().
    """
    return normalize_path(
        dist_location(dist)
    ).startswith(normalize_path(site_packages)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:11,代码来源:misc.py


注:本文中的pip._vendor.pkg_resources.Distribution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。