Commit ed3762fc authored by Paul Ganssle's avatar Paul Ganssle

Switch test_wheel over to subset-based test

This is both compatible with the old version of wheel (last one
supported under Python 3.3) and is more in line with our commitment,
which is that the wheel install provides at least these files.
parent 41882016
...@@ -92,39 +92,49 @@ def build_wheel(extra_file_defs=None, **kwargs): ...@@ -92,39 +92,49 @@ def build_wheel(extra_file_defs=None, **kwargs):
yield glob.glob(os.path.join(source_dir, 'dist', '*.whl'))[0] yield glob.glob(os.path.join(source_dir, 'dist', '*.whl'))[0]
def tree(root): def tree_set(root):
def depth(path): contents = set()
return len(path.split(os.path.sep))
def prefix(path_depth):
if not path_depth:
return ''
return '| ' * (path_depth - 1) + '|-- '
lines = []
root_depth = depth(root)
for dirpath, dirnames, filenames in os.walk(root): for dirpath, dirnames, filenames in os.walk(root):
dirnames.sort() for filename in filenames:
filenames.sort() contents.add(os.path.join(os.path.relpath(dirpath, root),
dir_depth = depth(dirpath) - root_depth filename))
if dir_depth > 0: return contents
lines.append('%s%s/' % (prefix(dir_depth - 1),
os.path.basename(dirpath)))
for f in filenames: def flatten_tree(tree):
lines.append('%s%s' % (prefix(dir_depth), f)) """Flatten nested dicts and lists into a full list of paths"""
return '\n'.join(lines) + '\n' output = set()
for node, contents in tree.items():
if isinstance(contents, dict):
def _check_wheel_install(filename, install_dir, install_tree, contents = flatten_tree(contents)
for elem in contents:
if isinstance(elem, dict):
output |= {os.path.join(node, val)
for val in flatten_tree(elem)}
else:
output.add(os.path.join(node, elem))
return output
def format_install_tree(tree):
return {x.format(
py_version=PY_MAJOR,
platform=get_platform(),
shlib_ext=get_config_var('EXT_SUFFIX') or get_config_var('SO'))
for x in tree}
def _check_wheel_install(filename, install_dir, install_tree_includes,
project_name, version, requires_txt): project_name, version, requires_txt):
w = Wheel(filename) w = Wheel(filename)
egg_path = os.path.join(install_dir, w.egg_name()) egg_path = os.path.join(install_dir, w.egg_name())
w.install_as_egg(egg_path) w.install_as_egg(egg_path)
if install_tree is not None: if install_tree_includes is not None:
install_tree = install_tree.format( install_tree = format_install_tree(install_tree_includes)
py_version=PY_MAJOR, exp = tree_set(install_dir)
platform=get_platform(), assert install_tree.issubset(exp), (install_tree - exp)
shlib_ext=get_config_var('EXT_SUFFIX') or get_config_var('SO')
)
assert install_tree == tree(install_dir)
metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO')) metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))
dist = Distribution.from_filename(egg_path, metadata=metadata) dist = Distribution.from_filename(egg_path, metadata=metadata)
assert dist.project_name == project_name assert dist.project_name == project_name
...@@ -157,18 +167,17 @@ WHEEL_INSTALL_TESTS = ( ...@@ -157,18 +167,17 @@ WHEEL_INSTALL_TESTS = (
setup_kwargs=dict( setup_kwargs=dict(
packages=['foo'], packages=['foo'],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': {
foo-1.0-py{py_version}.egg/ 'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt'
| |-- top_level.txt ],
|-- foo/ 'foo': ['__init__.py']
| |-- __init__.py }
''' }),
),
), ),
dict( dict(
...@@ -190,18 +199,19 @@ WHEEL_INSTALL_TESTS = ( ...@@ -190,18 +199,19 @@ WHEEL_INSTALL_TESTS = (
setup_kwargs=dict( setup_kwargs=dict(
data_files=[('data_dir', ['data.txt'])], data_files=[('data_dir', ['data.txt'])],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': {
foo-1.0-py{py_version}.egg/ 'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt'
| |-- top_level.txt ],
|-- data_dir/ 'data_dir': [
| |-- data.txt 'data.txt'
''' ]
), }
}),
), ),
dict( dict(
...@@ -258,17 +268,17 @@ WHEEL_INSTALL_TESTS = ( ...@@ -258,17 +268,17 @@ WHEEL_INSTALL_TESTS = (
sources=['extension.c']) sources=['extension.c'])
], ],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}-{platform}.egg': [
foo-1.0-py{py_version}-{platform}.egg/ 'extension{shlib_ext}',
|-- extension{shlib_ext} {'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt',
| |-- top_level.txt ]},
''' ]
), }),
), ),
dict( dict(
...@@ -282,17 +292,17 @@ WHEEL_INSTALL_TESTS = ( ...@@ -282,17 +292,17 @@ WHEEL_INSTALL_TESTS = (
setup_kwargs=dict( setup_kwargs=dict(
headers=['header.h'], headers=['header.h'],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': [
foo-1.0-py{py_version}.egg/ 'header.h',
|-- header.h {'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt',
| |-- top_level.txt ]},
''' ]
), }),
), ),
dict( dict(
...@@ -314,34 +324,37 @@ WHEEL_INSTALL_TESTS = ( ...@@ -314,34 +324,37 @@ WHEEL_INSTALL_TESTS = (
setup_kwargs=dict( setup_kwargs=dict(
scripts=['script.py', 'script.sh'], scripts=['script.py', 'script.sh'],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': {
foo-1.0-py{py_version}.egg/ 'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt',
| |-- top_level.txt {'scripts': [
| |-- scripts/ 'script.py',
| | |-- script.py 'script.sh'
| | |-- script.sh ]}
'''
), ]
}
})
), ),
dict( dict(
id='requires1', id='requires1',
install_requires='foobar==2.0', install_requires='foobar==2.0',
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': {
foo-1.0-py{py_version}.egg/ 'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'requires.txt',
| |-- requires.txt 'top_level.txt',
| |-- top_level.txt ]
'''), }
}),
requires_txt=DALS( requires_txt=DALS(
''' '''
foobar==2.0 foobar==2.0
...@@ -413,21 +426,22 @@ WHEEL_INSTALL_TESTS = ( ...@@ -413,21 +426,22 @@ WHEEL_INSTALL_TESTS = (
namespace_packages=['foo'], namespace_packages=['foo'],
packages=['foo.bar'], packages=['foo.bar'],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': [
foo-1.0-py{py_version}.egg/ 'foo-1.0-py{py_version}-nspkg.pth',
|-- foo-1.0-py{py_version}-nspkg.pth {'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'namespace_packages.txt',
| |-- namespace_packages.txt 'top_level.txt',
| |-- top_level.txt ]},
|-- foo/ {'foo': [
| |-- __init__.py '__init__.py',
| |-- bar/ {'bar': ['__init__.py']},
| | |-- __init__.py ]},
'''), ]
}),
), ),
dict( dict(
...@@ -448,20 +462,22 @@ WHEEL_INSTALL_TESTS = ( ...@@ -448,20 +462,22 @@ WHEEL_INSTALL_TESTS = (
packages=['foo'], packages=['foo'],
data_files=[('foo/data_dir', ['foo/data_dir/data.txt'])], data_files=[('foo/data_dir', ['foo/data_dir/data.txt'])],
), ),
install_tree=DALS( install_tree=flatten_tree({
''' 'foo-1.0-py{py_version}.egg': {
foo-1.0-py{py_version}.egg/ 'EGG-INFO': [
|-- EGG-INFO/ 'PKG-INFO',
| |-- PKG-INFO 'RECORD',
| |-- RECORD 'WHEEL',
| |-- WHEEL 'top_level.txt',
| |-- top_level.txt ],
|-- foo/ 'foo': [
| |-- __init__.py '__init__.py',
| |-- data_dir/ {'data_dir': [
| | |-- data.txt 'data.txt',
''' ]}
), ]
}
}),
), ),
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment