10
10
from pathlib import Path
11
11
from typing import Optional , TypeVar
12
12
13
+ from elftools .elf .elffile import ELFFile
14
+
15
+ from auditwheel .pool import POOL
16
+
13
17
from . import json
14
18
from .architecture import Architecture
15
19
from .elfutils import (
@@ -94,19 +98,19 @@ def get_wheel_elfdata(
94
98
shared_libraries_with_invalid_machine = []
95
99
96
100
platform_wheel = False
97
- for fn , elf in elf_file_filter (ctx .iter_files ()):
98
- # Check for invalid binary wheel format: no shared library should
99
- # be found in purelib
100
- so_name = fn .name
101
101
102
- # If this is in purelib, add it to the list of shared libraries in
103
- # purelib
104
- if any (p .name == "purelib" for p in fn .parents ):
105
- shared_libraries_in_purelib .append (so_name )
102
+ def inner (fn : Path ) -> None :
103
+ nonlocal \
104
+ platform_wheel , \
105
+ shared_libraries_in_purelib , \
106
+ uses_ucs2_symbols , \
107
+ uses_PyFPE_jbuf
108
+
109
+ with open (fn , "rb" ) as f :
110
+ elf = ELFFile (f )
111
+
112
+ so_name = fn .name
106
113
107
- # If at least one shared library exists in purelib, this is going
108
- # to fail and there's no need to do further checks
109
- if not shared_libraries_in_purelib :
110
114
log .debug ("processing: %s" , fn )
111
115
elftree = ldd (fn , exclude = exclude )
112
116
@@ -115,11 +119,11 @@ def get_wheel_elfdata(
115
119
if arch != wheel_policy .architecture .baseline :
116
120
shared_libraries_with_invalid_machine .append (so_name )
117
121
log .warning ("ignoring: %s with %s architecture" , so_name , arch )
118
- continue
122
+ return
119
123
except ValueError :
120
124
shared_libraries_with_invalid_machine .append (so_name )
121
125
log .warning ("ignoring: %s with unknown architecture" , so_name )
122
- continue
126
+ return
123
127
124
128
platform_wheel = True
125
129
@@ -148,6 +152,19 @@ def get_wheel_elfdata(
148
152
# its internal references later.
149
153
nonpy_elftree [fn ] = elftree
150
154
155
+ for fn , _elf in elf_file_filter (ctx .iter_files ()):
156
+ # Check for invalid binary wheel format: no shared library should
157
+ # be found in purelib
158
+ so_name = fn .name
159
+
160
+ # If this is in purelib, add it to the list of shared libraries in
161
+ # purelib
162
+ if any (p .name == "purelib" for p in fn .parents ):
163
+ shared_libraries_in_purelib .append (so_name )
164
+
165
+ if not shared_libraries_in_purelib :
166
+ POOL .submit (fn , inner , fn )
167
+
151
168
# If at least one shared library exists in purelib, raise an error
152
169
if shared_libraries_in_purelib :
153
170
libraries = "\n \t " .join (shared_libraries_in_purelib )
@@ -159,6 +176,8 @@ def get_wheel_elfdata(
159
176
)
160
177
raise RuntimeError (msg )
161
178
179
+ POOL .wait ()
180
+
162
181
if not platform_wheel :
163
182
raise NonPlatformWheel (
164
183
wheel_policy .architecture , shared_libraries_with_invalid_machine
0 commit comments