|
|
92c348 |
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
|
|
|
92c348 |
index b6be6f1f0..150ac4c1b 100644
|
|
|
92c348 |
--- a/setuptools/tests/test_wheel.py
|
|
|
92c348 |
+++ b/setuptools/tests/test_wheel.py
|
|
|
92c348 |
@@ -92,39 +92,49 @@ def build_wheel(extra_file_defs=None, **kwargs):
|
|
|
92c348 |
yield glob.glob(os.path.join(source_dir, 'dist', '*.whl'))[0]
|
|
|
92c348 |
|
|
|
92c348 |
|
|
|
92c348 |
-def tree(root):
|
|
|
92c348 |
- def depth(path):
|
|
|
92c348 |
- return len(path.split(os.path.sep))
|
|
|
92c348 |
- def prefix(path_depth):
|
|
|
92c348 |
- if not path_depth:
|
|
|
92c348 |
- return ''
|
|
|
92c348 |
- return '| ' * (path_depth - 1) + '|-- '
|
|
|
92c348 |
- lines = []
|
|
|
92c348 |
- root_depth = depth(root)
|
|
|
92c348 |
+def tree_set(root):
|
|
|
92c348 |
+ contents = set()
|
|
|
92c348 |
for dirpath, dirnames, filenames in os.walk(root):
|
|
|
92c348 |
- dirnames.sort()
|
|
|
92c348 |
- filenames.sort()
|
|
|
92c348 |
- dir_depth = depth(dirpath) - root_depth
|
|
|
92c348 |
- if dir_depth > 0:
|
|
|
92c348 |
- lines.append('%s%s/' % (prefix(dir_depth - 1),
|
|
|
92c348 |
- os.path.basename(dirpath)))
|
|
|
92c348 |
- for f in filenames:
|
|
|
92c348 |
- lines.append('%s%s' % (prefix(dir_depth), f))
|
|
|
92c348 |
- return '\n'.join(lines) + '\n'
|
|
|
92c348 |
-
|
|
|
92c348 |
-
|
|
|
92c348 |
-def _check_wheel_install(filename, install_dir, install_tree,
|
|
|
92c348 |
+ for filename in filenames:
|
|
|
92c348 |
+ contents.add(os.path.join(os.path.relpath(dirpath, root),
|
|
|
92c348 |
+ filename))
|
|
|
92c348 |
+ return contents
|
|
|
92c348 |
+
|
|
|
92c348 |
+
|
|
|
92c348 |
+def flatten_tree(tree):
|
|
|
92c348 |
+ """Flatten nested dicts and lists into a full list of paths"""
|
|
|
92c348 |
+ output = set()
|
|
|
92c348 |
+ for node, contents in tree.items():
|
|
|
92c348 |
+ if isinstance(contents, dict):
|
|
|
92c348 |
+ contents = flatten_tree(contents)
|
|
|
92c348 |
+
|
|
|
92c348 |
+ for elem in contents:
|
|
|
92c348 |
+ if isinstance(elem, dict):
|
|
|
92c348 |
+ output |= {os.path.join(node, val)
|
|
|
92c348 |
+ for val in flatten_tree(elem)}
|
|
|
92c348 |
+ else:
|
|
|
92c348 |
+ output.add(os.path.join(node, elem))
|
|
|
92c348 |
+ return output
|
|
|
92c348 |
+
|
|
|
92c348 |
+
|
|
|
92c348 |
+def format_install_tree(tree):
|
|
|
92c348 |
+ return {x.format(
|
|
|
92c348 |
+ py_version=PY_MAJOR,
|
|
|
92c348 |
+ platform=get_platform(),
|
|
|
92c348 |
+ shlib_ext=get_config_var('EXT_SUFFIX') or get_config_var('SO'))
|
|
|
92c348 |
+ for x in tree}
|
|
|
92c348 |
+
|
|
|
92c348 |
+
|
|
|
92c348 |
+def _check_wheel_install(filename, install_dir, install_tree_includes,
|
|
|
92c348 |
project_name, version, requires_txt):
|
|
|
92c348 |
w = Wheel(filename)
|
|
|
92c348 |
egg_path = os.path.join(install_dir, w.egg_name())
|
|
|
92c348 |
w.install_as_egg(egg_path)
|
|
|
92c348 |
- if install_tree is not None:
|
|
|
92c348 |
- install_tree = install_tree.format(
|
|
|
92c348 |
- py_version=PY_MAJOR,
|
|
|
92c348 |
- platform=get_platform(),
|
|
|
92c348 |
- shlib_ext=get_config_var('EXT_SUFFIX') or get_config_var('SO')
|
|
|
92c348 |
- )
|
|
|
92c348 |
- assert install_tree == tree(install_dir)
|
|
|
92c348 |
+ if install_tree_includes is not None:
|
|
|
92c348 |
+ install_tree = format_install_tree(install_tree_includes)
|
|
|
92c348 |
+ exp = tree_set(install_dir)
|
|
|
92c348 |
+ assert install_tree.issubset(exp), (install_tree - exp)
|
|
|
92c348 |
+
|
|
|
92c348 |
metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))
|
|
|
92c348 |
dist = Distribution.from_filename(egg_path, metadata=metadata)
|
|
|
92c348 |
assert dist.project_name == project_name
|
|
|
92c348 |
@@ -157,20 +167,17 @@ def __repr__(self):
|
|
|
92c348 |
setup_kwargs=dict(
|
|
|
92c348 |
packages=['foo'],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- |-- foo/
|
|
|
92c348 |
- | |-- __init__.py
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': {
|
|
|
92c348 |
+ 'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt'
|
|
|
92c348 |
+ ],
|
|
|
92c348 |
+ 'foo': ['__init__.py']
|
|
|
92c348 |
+ }
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
@@ -192,20 +199,19 @@ def __repr__(self):
|
|
|
92c348 |
setup_kwargs=dict(
|
|
|
92c348 |
data_files=[('data_dir', ['data.txt'])],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- |-- data_dir/
|
|
|
92c348 |
- | |-- data.txt
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': {
|
|
|
92c348 |
+ 'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt'
|
|
|
92c348 |
+ ],
|
|
|
92c348 |
+ 'data_dir': [
|
|
|
92c348 |
+ 'data.txt'
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
@@ -262,19 +268,17 @@ def __repr__(self):
|
|
|
92c348 |
sources=['extension.c'])
|
|
|
92c348 |
],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}-{platform}.egg/
|
|
|
92c348 |
- |-- extension{shlib_ext}
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}-{platform}.egg': [
|
|
|
92c348 |
+ 'extension{shlib_ext}',
|
|
|
92c348 |
+ {'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ ]},
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
@@ -288,19 +292,17 @@ def __repr__(self):
|
|
|
92c348 |
setup_kwargs=dict(
|
|
|
92c348 |
headers=['header.h'],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- header.h
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': [
|
|
|
92c348 |
+ 'header.h',
|
|
|
92c348 |
+ {'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ ]},
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
@@ -322,38 +324,37 @@ def __repr__(self):
|
|
|
92c348 |
setup_kwargs=dict(
|
|
|
92c348 |
scripts=['script.py', 'script.sh'],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- | |-- scripts/
|
|
|
92c348 |
- | | |-- script.py
|
|
|
92c348 |
- | | |-- script.sh
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': {
|
|
|
92c348 |
+ 'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ {'scripts': [
|
|
|
92c348 |
+ 'script.py',
|
|
|
92c348 |
+ 'script.sh'
|
|
|
92c348 |
+ ]}
|
|
|
92c348 |
+
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }
|
|
|
92c348 |
+ })
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
id='requires1',
|
|
|
92c348 |
install_requires='foobar==2.0',
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- requires.txt
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- '''),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': {
|
|
|
92c348 |
+ 'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'requires.txt',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
requires_txt=DALS(
|
|
|
92c348 |
'''
|
|
|
92c348 |
foobar==2.0
|
|
|
92c348 |
@@ -425,23 +426,22 @@ def __repr__(self):
|
|
|
92c348 |
namespace_packages=['foo'],
|
|
|
92c348 |
packages=['foo.bar'],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- foo-1.0-py{py_version}-nspkg.pth
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- namespace_packages.txt
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- |-- foo/
|
|
|
92c348 |
- | |-- __init__.py
|
|
|
92c348 |
- | |-- bar/
|
|
|
92c348 |
- | | |-- __init__.py
|
|
|
92c348 |
- '''),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': [
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}-nspkg.pth',
|
|
|
92c348 |
+ {'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'namespace_packages.txt',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ ]},
|
|
|
92c348 |
+ {'foo': [
|
|
|
92c348 |
+ '__init__.py',
|
|
|
92c348 |
+ {'bar': ['__init__.py']},
|
|
|
92c348 |
+ ]},
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
dict(
|
|
|
92c348 |
@@ -462,22 +462,22 @@ def __repr__(self):
|
|
|
92c348 |
packages=['foo'],
|
|
|
92c348 |
data_files=[('foo/data_dir', ['foo/data_dir/data.txt'])],
|
|
|
92c348 |
),
|
|
|
92c348 |
- install_tree=DALS(
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- foo-1.0-py{py_version}.egg/
|
|
|
92c348 |
- |-- EGG-INFO/
|
|
|
92c348 |
- | |-- DESCRIPTION.rst
|
|
|
92c348 |
- | |-- PKG-INFO
|
|
|
92c348 |
- | |-- RECORD
|
|
|
92c348 |
- | |-- WHEEL
|
|
|
92c348 |
- | |-- metadata.json
|
|
|
92c348 |
- | |-- top_level.txt
|
|
|
92c348 |
- |-- foo/
|
|
|
92c348 |
- | |-- __init__.py
|
|
|
92c348 |
- | |-- data_dir/
|
|
|
92c348 |
- | | |-- data.txt
|
|
|
92c348 |
- '''
|
|
|
92c348 |
- ),
|
|
|
92c348 |
+ install_tree=flatten_tree({
|
|
|
92c348 |
+ 'foo-1.0-py{py_version}.egg': {
|
|
|
92c348 |
+ 'EGG-INFO': [
|
|
|
92c348 |
+ 'PKG-INFO',
|
|
|
92c348 |
+ 'RECORD',
|
|
|
92c348 |
+ 'WHEEL',
|
|
|
92c348 |
+ 'top_level.txt',
|
|
|
92c348 |
+ ],
|
|
|
92c348 |
+ 'foo': [
|
|
|
92c348 |
+ '__init__.py',
|
|
|
92c348 |
+ {'data_dir': [
|
|
|
92c348 |
+ 'data.txt',
|
|
|
92c348 |
+ ]}
|
|
|
92c348 |
+ ]
|
|
|
92c348 |
+ }
|
|
|
92c348 |
+ }),
|
|
|
92c348 |
),
|
|
|
92c348 |
|
|
|
92c348 |
)
|