本文整理汇总了Python中wheel.install.WheelFile方法的典型用法代码示例。如果您正苦于以下问题:Python install.WheelFile方法的具体用法?Python install.WheelFile怎么用?Python install.WheelFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wheel.install
的用法示例。
在下文中一共展示了install.WheelFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_install
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install import WheelFile [as 别名]
def test_install():
tempdir = mkdtemp()
def get_supported():
return list(wheel.pep425tags.get_supported()) + [('py3', 'none', 'win32')]
whl = WheelFile(TESTWHEEL, context=get_supported)
assert whl.supports_current_python(get_supported)
try:
locs = {}
for key in ('purelib', 'platlib', 'scripts', 'headers', 'data'):
locs[key] = os.path.join(tempdir, key)
os.mkdir(locs[key])
whl.install(overrides=locs)
assert len(os.listdir(locs['purelib'])) == 0
assert check(locs['platlib'], 'hello.pyd')
assert check(locs['platlib'], 'hello', 'hello.py')
assert check(locs['platlib'], 'hello', '__init__.py')
assert check(locs['data'], 'hello.dat')
assert check(locs['headers'], 'hello.dat')
assert check(locs['scripts'], 'hello.sh')
assert check(locs['platlib'], 'test-1.0.dist-info', 'RECORD')
finally:
shutil.rmtree(tempdir)
示例2: assert_winfo_similar
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install 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)
示例3: test_compatibility_tags
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install import WheelFile [as 别名]
def test_compatibility_tags():
"""Test compatibilty tags are working."""
wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
assert (list(wf.compatibility_tags) ==
[('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
assert (wf.arity == 2)
wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
wf2_info = wf2.parsed_filename.groupdict()
assert wf2_info['build'] == '1st', wf2_info
示例4: test_pick_best
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install import WheelFile [as 别名]
def test_pick_best():
"""Test the wheel ranking algorithm."""
def get_tags(res):
info = res[-1].parsed_filename.groupdict()
return info['pyver'], info['abi'], info['plat']
cand_tags = [('py27', 'noabi', 'noarch'), ('py26', 'noabi', 'noarch'),
('cp27', 'noabi', 'linux_i686'),
('cp26', 'noabi', 'linux_i686'),
('cp27', 'noabi', 'linux_x86_64'),
('cp26', 'noabi', 'linux_x86_64')]
cand_wheels = [WheelFile('testpkg-1.0-%s-%s-%s.whl' % t)
for t in cand_tags]
supported = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
supported2 = [('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch'),
('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch')]
supported3 = [('cp26', 'noabi', 'linux_i686'), ('py26', 'noabi', 'noarch'),
('cp27', 'noabi', 'linux_i686'), ('py27', 'noabi', 'noarch')]
for supp in (supported, supported2, supported3):
context = lambda: list(supp)
for wheel in cand_wheels:
wheel.context = context
best = max(cand_wheels)
assert list(best.tags)[0] == supp[0]
# assert_equal(
# list(map(get_tags, pick_best(cand_wheels, supp, top=False))), supp)
示例5: make_wheel
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install import WheelFile [as 别名]
def make_wheel(name, ver, pyver, abi, arch):
name = WHEELPAT % dict(name=name, ver=ver, pyver=pyver, abi=abi,
arch=arch)
return WheelFile(name)
# This relies on the fact that generate_supported will always return the
# exact pyver, abi, and architecture for its first (best) match.
示例6: _split_filename
# 需要导入模块: from wheel import install [as 别名]
# 或者: from wheel.install import WheelFile [as 别名]
def _split_filename(filename):
""" Split a .whl or .tar.gz distribution file name
into a (package_name, version) tuple
>>> _split_filename('abc-1.1.tar.gz')
('abc', <Version('1.1')>)
>>> _split_filename('dir/abc-1.1.tar.gz')
('abc', <Version('1.1')>)
>>> _split_filename('a_bc-1.1.tar.gz')
('a-bc', <Version('1.1')>)
>>> _split_filename('a_b-c-1.1.tar.gz')
('a-b-c', <Version('1.1')>)
>>> _split_filename('mis_builder-3.1.1.99.dev17-py2-none-any.whl')
('mis-builder', <Version('3.1.1.99.dev17')>)
>>> _split_filename('a/b/mis_builder-3.1.1.99.dev17-py2-none-any.whl')
('mis-builder', <Version('3.1.1.99.dev17')>)
"""
basename = os.path.basename(filename)
if basename.endswith('.whl'):
wheelfile = WheelFile(basename)
package_name = wheelfile.parsed_filename.group('name')
package_ver = wheelfile.parsed_filename.group('ver')
elif basename.endswith('.tar.gz'):
package_ver = basename.split('-')[-1][:-7]
package_name = basename[:-(len(package_ver) + 8)]
else:
raise RuntimeError("Unrecognized file type %s" % (filename,))
package_name = package_name.replace('_', '-')
package_ver = parse_version(package_ver)
return package_name, package_ver