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


Python pkg_resources.to_filename方法代码示例

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


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

示例1: wheel_filename

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import to_filename [as 别名]
def wheel_filename(self) -> str:
        name = to_filename(self.meta.project_name)
        version = to_filename(safe_version(self.meta.version))
        return f"{name}-{version}-{self.tag}.whl" 
开发者ID:frostming,项目名称:pdm,代码行数:6,代码来源:wheel.py

示例2: dist_info_name

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import to_filename [as 别名]
def dist_info_name(self) -> str:
        name = to_filename(self.meta.project_name)
        version = to_filename(safe_version(self.meta.version))
        return f"{name}-{version}.dist-info" 
开发者ID:frostming,项目名称:pdm,代码行数:6,代码来源:wheel.py

示例3: build

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import to_filename [as 别名]
def build(self, build_dir: str, **kwargs):
        if not os.path.exists(build_dir):
            os.makedirs(build_dir, exist_ok=True)

        stream.echo("- Building {}...".format(stream.cyan("sdist")))
        version = to_filename(safe_version(self.meta.version))

        target = os.path.join(
            build_dir, "{}-{}.tar.gz".format(self.meta.project_name, version)
        )
        tar = tarfile.open(target, mode="w:gz", format=tarfile.PAX_FORMAT)

        try:
            tar_dir = "{}-{}".format(self.meta.project_name, version)

            files_to_add = self.find_files_to_add(True)

            for relpath in files_to_add:
                tar.add(
                    relpath,
                    arcname=os.path.join(tar_dir, str(relpath)),
                    recursive=False,
                )
                stream.echo(f" - Adding: {relpath}", verbosity=stream.DETAIL)

            fd, temp_name = tempfile.mkstemp(prefix="pkg-info")
            pkg_info = self.format_pkginfo(False).encode("utf-8")
            with open(fd, "wb") as f:
                f.write(pkg_info)
            tar.add(
                temp_name, arcname=os.path.join(tar_dir, "PKG-INFO"), recursive=False
            )
            stream.echo(" - Adding: PKG-INFO", verbosity=stream.DETAIL)
        finally:
            tar.close()

        stream.echo("- Built {}".format(stream.cyan(os.path.basename(target))))

        return target 
开发者ID:frostming,项目名称:pdm,代码行数:41,代码来源:sdist.py

示例4: get_local_dist_metadata_filepath

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import to_filename [as 别名]
def get_local_dist_metadata_filepath(dist):
    # Dist filename syntax
    # name ["-" version ["-py" pyver ["-" required_platform]]] "." ext
    # https://setuptools.readthedocs.io/en/latest/formats.html#filename-embedded-metadata

    def valid_component(component):
        return component[1]

    # Stop taking filename components at the first missing/invalid component
    filename_component = takewhile(valid_component, (
        ('',    pkg_resources.to_filename(pkg_resources.safe_name(dist.project_name))),
        ('-',   pkg_resources.to_filename(pkg_resources.safe_version(dist.version))),
        ('-py', dist.py_version),
        ('-',   dist.platform),
    ))
    filename = ''.join(chain(*filename_component))

    if isinstance(dist, pkg_resources.EggInfoDistribution):
        ext = 'egg-info'
        metadata_file = 'PKG-INFO'
    elif isinstance(dist, pkg_resources.DistInfoDistribution):
        ext = 'dist-info'
        metadata_file = 'METADATA'
    elif isinstance(dist, pkg_resources.Distribution):
        ext = os.path.join('egg', 'EGG-INFO')
        metadata_file = 'PKG-INFO'
    else:
        ext = None
        metadata_file = None

    filename = '{}.{}'.format(filename, ext)
    path = os.path.join(dist.location, filename, metadata_file)

    if ext:
        return path
    else:
        return None 
开发者ID:phildini,项目名称:thanks,代码行数:39,代码来源:package_tools.py


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