1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
From 41882016dbd6b334e6e10e2c3ac5afb9f5793ede Mon Sep 17 00:00:00 2001
From: Paul Ganssle <paul@ganssle.io>
Date: Fri, 6 Apr 2018 17:07:44 -0400
Subject: [PATCH 1/2] Update wheel tests to reflect latest version
---
setuptools/tests/test_wheel.py | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index b6be6f1f0..d8d5ddb23 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -161,11 +161,9 @@ def __repr__(self):
'''
foo-1.0-py{py_version}.egg/
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
|-- foo/
| |-- __init__.py
@@ -196,11 +194,9 @@ def __repr__(self):
'''
foo-1.0-py{py_version}.egg/
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
|-- data_dir/
| |-- data.txt
@@ -267,11 +263,9 @@ def __repr__(self):
foo-1.0-py{py_version}-{platform}.egg/
|-- extension{shlib_ext}
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
'''
),
@@ -293,11 +287,9 @@ def __repr__(self):
foo-1.0-py{py_version}.egg/
|-- header.h
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
'''
),
@@ -326,11 +318,9 @@ def __repr__(self):
'''
foo-1.0-py{py_version}.egg/
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
| |-- scripts/
| | |-- script.py
@@ -346,11 +336,9 @@ def __repr__(self):
'''
foo-1.0-py{py_version}.egg/
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- requires.txt
| |-- top_level.txt
'''),
@@ -430,11 +418,9 @@ def __repr__(self):
foo-1.0-py{py_version}.egg/
|-- foo-1.0-py{py_version}-nspkg.pth
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- namespace_packages.txt
| |-- top_level.txt
|-- foo/
@@ -466,11 +452,9 @@ def __repr__(self):
'''
foo-1.0-py{py_version}.egg/
|-- EGG-INFO/
- | |-- DESCRIPTION.rst
| |-- PKG-INFO
| |-- RECORD
| |-- WHEEL
- | |-- metadata.json
| |-- top_level.txt
|-- foo/
| |-- __init__.py
From ed3762fc7d16174a54b2fa83af1996decafd756f Mon Sep 17 00:00:00 2001
From: Paul Ganssle <paul@ganssle.io>
Date: Sat, 7 Apr 2018 13:38:31 -0400
Subject: [PATCH 2/2] 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.
---
setuptools/tests/test_wheel.py | 268 ++++++++++++++++++++++-------------------
1 file changed, 142 insertions(+), 126 deletions(-)
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index d8d5ddb23..150ac4c1b 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -92,39 +92,49 @@ def build_wheel(extra_file_defs=None, **kwargs):
yield glob.glob(os.path.join(source_dir, 'dist', '*.whl'))[0]
-def tree(root):
- def depth(path):
- 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)
+def tree_set(root):
+ contents = set()
for dirpath, dirnames, filenames in os.walk(root):
- dirnames.sort()
- filenames.sort()
- dir_depth = depth(dirpath) - root_depth
- if dir_depth > 0:
- lines.append('%s%s/' % (prefix(dir_depth - 1),
- os.path.basename(dirpath)))
- for f in filenames:
- lines.append('%s%s' % (prefix(dir_depth), f))
- return '\n'.join(lines) + '\n'
-
-
-def _check_wheel_install(filename, install_dir, install_tree,
+ for filename in filenames:
+ contents.add(os.path.join(os.path.relpath(dirpath, root),
+ filename))
+ return contents
+
+
+def flatten_tree(tree):
+ """Flatten nested dicts and lists into a full list of paths"""
+ output = set()
+ for node, contents in tree.items():
+ if isinstance(contents, dict):
+ 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):
w = Wheel(filename)
egg_path = os.path.join(install_dir, w.egg_name())
w.install_as_egg(egg_path)
- if install_tree is not None:
- install_tree = install_tree.format(
- py_version=PY_MAJOR,
- platform=get_platform(),
- shlib_ext=get_config_var('EXT_SUFFIX') or get_config_var('SO')
- )
- assert install_tree == tree(install_dir)
+ if install_tree_includes is not None:
+ install_tree = format_install_tree(install_tree_includes)
+ exp = tree_set(install_dir)
+ assert install_tree.issubset(exp), (install_tree - exp)
+
metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))
dist = Distribution.from_filename(egg_path, metadata=metadata)
assert dist.project_name == project_name
@@ -157,18 +167,17 @@ def __repr__(self):
setup_kwargs=dict(
packages=['foo'],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- |-- foo/
- | |-- __init__.py
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': {
+ 'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt'
+ ],
+ 'foo': ['__init__.py']
+ }
+ }),
),
dict(
@@ -190,18 +199,19 @@ def __repr__(self):
setup_kwargs=dict(
data_files=[('data_dir', ['data.txt'])],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- |-- data_dir/
- | |-- data.txt
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': {
+ 'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt'
+ ],
+ 'data_dir': [
+ 'data.txt'
+ ]
+ }
+ }),
),
dict(
@@ -258,17 +268,17 @@ def __repr__(self):
sources=['extension.c'])
],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}-{platform}.egg/
- |-- extension{shlib_ext}
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}-{platform}.egg': [
+ 'extension{shlib_ext}',
+ {'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt',
+ ]},
+ ]
+ }),
),
dict(
@@ -282,17 +292,17 @@ def __repr__(self):
setup_kwargs=dict(
headers=['header.h'],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- header.h
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': [
+ 'header.h',
+ {'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt',
+ ]},
+ ]
+ }),
),
dict(
@@ -314,34 +324,37 @@ def __repr__(self):
setup_kwargs=dict(
scripts=['script.py', 'script.sh'],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- | |-- scripts/
- | | |-- script.py
- | | |-- script.sh
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': {
+ 'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt',
+ {'scripts': [
+ 'script.py',
+ 'script.sh'
+ ]}
+
+ ]
+ }
+ })
),
dict(
id='requires1',
install_requires='foobar==2.0',
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- requires.txt
- | |-- top_level.txt
- '''),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': {
+ 'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'requires.txt',
+ 'top_level.txt',
+ ]
+ }
+ }),
requires_txt=DALS(
'''
foobar==2.0
@@ -413,21 +426,22 @@ def __repr__(self):
namespace_packages=['foo'],
packages=['foo.bar'],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- foo-1.0-py{py_version}-nspkg.pth
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- namespace_packages.txt
- | |-- top_level.txt
- |-- foo/
- | |-- __init__.py
- | |-- bar/
- | | |-- __init__.py
- '''),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': [
+ 'foo-1.0-py{py_version}-nspkg.pth',
+ {'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'namespace_packages.txt',
+ 'top_level.txt',
+ ]},
+ {'foo': [
+ '__init__.py',
+ {'bar': ['__init__.py']},
+ ]},
+ ]
+ }),
),
dict(
@@ -448,20 +462,22 @@ def __repr__(self):
packages=['foo'],
data_files=[('foo/data_dir', ['foo/data_dir/data.txt'])],
),
- install_tree=DALS(
- '''
- foo-1.0-py{py_version}.egg/
- |-- EGG-INFO/
- | |-- PKG-INFO
- | |-- RECORD
- | |-- WHEEL
- | |-- top_level.txt
- |-- foo/
- | |-- __init__.py
- | |-- data_dir/
- | | |-- data.txt
- '''
- ),
+ install_tree=flatten_tree({
+ 'foo-1.0-py{py_version}.egg': {
+ 'EGG-INFO': [
+ 'PKG-INFO',
+ 'RECORD',
+ 'WHEEL',
+ 'top_level.txt',
+ ],
+ 'foo': [
+ '__init__.py',
+ {'data_dir': [
+ 'data.txt',
+ ]}
+ ]
+ }
+ }),
),
)
|