當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。