@@ -279,14 +279,15 @@ def get_dependencies_sizes(
279
279
wheel_data = response .content
280
280
281
281
with tempfile .TemporaryDirectory () as tmpdir :
282
- wheel_path = Path (tmpdir ) / "package.whl "
282
+ wheel_path = Path (tmpdir ) / "package"
283
283
with open (wheel_path , "wb" ) as f :
284
284
f .write (wheel_data )
285
-
286
285
if compressed :
287
286
with zipfile .ZipFile (wheel_path , "r" ) as zip_ref :
288
287
size = sum (
289
- zinfo .compress_size for zinfo in zip_ref .infolist () if "test" not in zinfo .filename .lower ()
288
+ zinfo .compress_size
289
+ for zinfo in zip_ref .infolist ()
290
+ if not is_excluded_from_wheel (zinfo .filename )
290
291
)
291
292
else :
292
293
extract_path = Path (tmpdir ) / "extracted"
@@ -295,12 +296,14 @@ def get_dependencies_sizes(
295
296
296
297
size = 0
297
298
for dirpath , _ , filenames in os .walk (extract_path ):
298
- if "test" in dirpath .lower ():
299
+ rel_dir = os .path .relpath (dirpath , extract_path )
300
+ if is_excluded_from_wheel (rel_dir ):
299
301
continue
300
302
for name in filenames :
301
- if "test" in name .lower ():
303
+ file_path = os .path .join (dirpath , name ) # solo si es blob??
304
+ rel_file = os .path .relpath (file_path , extract_path )
305
+ if is_excluded_from_wheel (rel_file ):
302
306
continue
303
- file_path = os .path .join (dirpath , name )
304
307
size += os .path .getsize (file_path )
305
308
306
309
file_data .append (
@@ -316,6 +319,58 @@ def get_dependencies_sizes(
316
319
return file_data
317
320
318
321
322
+ def is_excluded_from_wheel (path : str ) -> bool :
323
+ excluded_test_paths = [
324
+ os .path .normpath (path )
325
+ for path in [
326
+ 'idlelib/idle_test' ,
327
+ 'bs4/tests' ,
328
+ 'Cryptodome/SelfTest' ,
329
+ 'gssapi/tests' ,
330
+ 'keystoneauth1/tests' ,
331
+ 'openstack/tests' ,
332
+ 'os_service_types/tests' ,
333
+ 'pbr/tests' ,
334
+ 'pkg_resources/tests' ,
335
+ 'psutil/tests' ,
336
+ 'securesystemslib/_vendor/ed25519/test_data' ,
337
+ 'setuptools/_distutils/tests' ,
338
+ 'setuptools/tests' ,
339
+ 'simplejson/tests' ,
340
+ 'stevedore/tests' ,
341
+ 'supervisor/tests' ,
342
+ 'test' , # cm-client
343
+ 'vertica_python/tests' ,
344
+ 'websocket/tests' ,
345
+ ]
346
+ ]
347
+
348
+ type_annot_libraries = [
349
+ 'krb5' ,
350
+ 'Cryptodome' ,
351
+ 'ddtrace' ,
352
+ 'pyVmomi' ,
353
+ 'gssapi' ,
354
+ ]
355
+ # print('path:', path)
356
+ rel_path = Path (path ).as_posix ()
357
+
358
+ # Test folders
359
+ for test_folder in excluded_test_paths :
360
+ if rel_path == test_folder or rel_path .startswith (test_folder + '/' ):
361
+ return True
362
+
363
+ # Python type annotations
364
+ path_parts = Path (rel_path ).parts
365
+ if path_parts :
366
+ dependency_name = path_parts [0 ]
367
+ if dependency_name in type_annot_libraries :
368
+ if path .endswith ('.pyi' ) or os .path .basename (path ) == 'py.typed' :
369
+ return True
370
+
371
+ return False
372
+
373
+
319
374
def format_modules (
320
375
modules : list [FileDataEntry ],
321
376
platform : str ,
@@ -459,9 +514,7 @@ def export_format(
459
514
else (
460
515
f"{ version } _{ size_type } _{ mode } .csv"
461
516
if version
462
- else f"{ platform } _{ size_type } _{ mode } .csv"
463
- if platform
464
- else f"{ size_type } _{ mode } .csv"
517
+ else f"{ platform } _{ size_type } _{ mode } .csv" if platform else f"{ size_type } _{ mode } .csv"
465
518
)
466
519
)
467
520
save_csv (app , modules , csv_filename )
@@ -473,9 +526,7 @@ def export_format(
473
526
else (
474
527
f"{ version } _{ size_type } _{ mode } .json"
475
528
if version
476
- else f"{ platform } _{ size_type } _{ mode } .json"
477
- if platform
478
- else f"{ size_type } _{ mode } .json"
529
+ else f"{ platform } _{ size_type } _{ mode } .json" if platform else f"{ size_type } _{ mode } .json"
479
530
)
480
531
)
481
532
save_json (app , json_filename , modules )
@@ -487,9 +538,7 @@ def export_format(
487
538
else (
488
539
f"{ version } _{ size_type } _{ mode } .md"
489
540
if version
490
- else f"{ platform } _{ size_type } _{ mode } .md"
491
- if platform
492
- else f"{ size_type } _{ mode } .md"
541
+ else f"{ platform } _{ size_type } _{ mode } .md" if platform else f"{ size_type } _{ mode } .md"
493
542
)
494
543
)
495
544
save_markdown (app , "Status" , modules , markdown_filename )
0 commit comments