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


Python wheelfile.WheelFile方法代码示例

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


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

示例1: assert_winfo_similar

# 需要导入模块: from wheel import wheelfile [as 别名]
# 或者: from wheel.wheelfile import WheelFile [as 别名]
def assert_winfo_similar(whl_fname, exp_items, drop_version=True):
    wf = WheelFile(whl_fname)
    wheel_parts = wf.parsed_filename.groupdict()
    # Info can contain duplicate keys (e.g. Tag)
    w_info = sorted(get_info(wf).items())
    if drop_version:
        w_info = _filter_key(w_info, 'Wheel-Version')
        exp_items = _filter_key(exp_items, 'Wheel-Version')
    assert_equal(len(exp_items), len(w_info))
    # Extract some information from actual values
    wheel_parts['pip_version'] = dict(w_info)['Generator'].split()[1]
    for (key1, value1), (key2, value2) in zip(exp_items, w_info):
        assert_equal(key1, key2)
        value1 = value1.format(**wheel_parts)
        assert_equal(value1, value2) 
开发者ID:matthew-brett,项目名称:delocate,代码行数:17,代码来源:test_wheeltools.py

示例2: pack

# 需要导入模块: from wheel import wheelfile [as 别名]
# 或者: from wheel.wheelfile import WheelFile [as 别名]
def pack(directory, dest_dir, build_number):
    """Repack a previously unpacked wheel directory into a new wheel file.

    The .dist-info/WHEEL file must contain one or more tags so that the target
    wheel file name can be determined.

    :param directory: The unpacked wheel directory
    :param dest_dir: Destination directory (defaults to the current directory)
    """
    # Find the .dist-info directory
    dist_info_dirs = [fn for fn in os.listdir(directory)
                      if os.path.isdir(os.path.join(directory, fn)) and DIST_INFO_RE.match(fn)]
    if len(dist_info_dirs) > 1:
        raise WheelError('Multiple .dist-info directories found in {}'.format(directory))
    elif not dist_info_dirs:
        raise WheelError('No .dist-info directories found in {}'.format(directory))

    # Determine the target wheel filename
    dist_info_dir = dist_info_dirs[0]
    name_version = DIST_INFO_RE.match(dist_info_dir).group('namever')

    # Add the build number if specific
    if build_number:
        name_version += '-' + build_number

    # Read the tags from .dist-info/WHEEL
    with open(os.path.join(directory, dist_info_dir, 'WHEEL')) as f:
        tags = [line.split(' ')[1].rstrip() for line in f if line.startswith('Tag: ')]
        if not tags:
            raise WheelError('No tags present in {}/WHEEL; cannot determine target wheel filename'
                             .format(dist_info_dir))

    # Reassemble the tags for the wheel file
    impls = sorted({tag.split('-')[0] for tag in tags})
    abivers = sorted({tag.split('-')[1] for tag in tags})
    platforms = sorted({tag.split('-')[2] for tag in tags})
    tagline = '-'.join(['.'.join(impls), '.'.join(abivers), '.'.join(platforms)])

    # Repack the wheel
    wheel_path = os.path.join(dest_dir, '{}-{}.whl'.format(name_version, tagline))
    with WheelFile(wheel_path, 'w') as wf:
        print("Repacking wheel as {}...".format(wheel_path), end='')
        sys.stdout.flush()
        wf.write_files(directory)

    print('OK') 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:48,代码来源:pack.py

示例3: pack

# 需要导入模块: from wheel import wheelfile [as 别名]
# 或者: from wheel.wheelfile import WheelFile [as 别名]
def pack(directory, dest_dir):
    """Repack a previously unpacked wheel directory into a new wheel file.

    The .dist-info/WHEEL file must contain one or more tags so that the target
    wheel file name can be determined.

    :param directory: The unpacked wheel directory
    :param dest_dir: Destination directory (defaults to the current directory)
    """
    # Find the .dist-info directory
    dist_info_dirs = [fn for fn in os.listdir(directory)
                      if os.path.isdir(os.path.join(directory, fn)) and DIST_INFO_RE.match(fn)]
    if len(dist_info_dirs) > 1:
        raise WheelError('Multiple .dist-info directories found in {}'.format(directory))
    elif not dist_info_dirs:
        raise WheelError('No .dist-info directories found in {}'.format(directory))

    # Determine the target wheel filename
    dist_info_dir = dist_info_dirs[0]
    name_version = DIST_INFO_RE.match(dist_info_dir).group('namever')

    # Read the tags from .dist-info/WHEEL
    with open(os.path.join(directory, dist_info_dir, 'WHEEL')) as f:
        tags = [line.split(' ')[1].rstrip() for line in f if line.startswith('Tag: ')]
        if not tags:
            raise WheelError('No tags present in {}/WHEEL; cannot determine target wheel filename'
                             .format(dist_info_dir))

    # Reassemble the tags for the wheel file
    impls = sorted({tag.split('-')[0] for tag in tags})
    abivers = sorted({tag.split('-')[1] for tag in tags})
    platforms = sorted({tag.split('-')[2] for tag in tags})
    tagline = '-'.join(['.'.join(impls), '.'.join(abivers), '.'.join(platforms)])

    # Repack the wheel
    wheel_path = os.path.join(dest_dir, '{}-{}.whl'.format(name_version, tagline))
    with WheelFile(wheel_path, 'w') as wf:
        print("Repacking wheel as {}...".format(wheel_path), end='')
        sys.stdout.flush()
        wf.write_files(directory)

    print('OK') 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:44,代码来源:pack.py


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