12
12
from os .path import isabs
13
13
from pathlib import Path
14
14
from subprocess import check_call
15
+ from threading import Lock
15
16
16
17
from auditwheel .patcher import ElfPatcher
17
18
@@ -87,13 +88,17 @@ def repair_wheel(
87
88
raise ValueError (msg )
88
89
89
90
new_soname , new_path = copylib (src_path , dest_dir , patcher , dry = True )
90
- if not new_path . exists () and str (new_path ) not in copy_works :
91
- copy_works [str ( new_path ) ] = pool .submit (
91
+ if ( new_path_key := str (new_path ) ) not in copy_works :
92
+ copy_works [new_path_key ] = pool .submit (
92
93
copylib , src_path , dest_dir , patcher
93
94
)
95
+ else :
96
+ if copy_works [new_path_key ].running () or copy_works [new_path_key ].done ():
97
+ assert new_path .exists ()
94
98
soname_map [soname ] = (new_soname , new_path )
95
99
replacements .append ((soname , new_soname ))
96
100
101
+ # Replace rpath do not need copy to be done
97
102
def _inner_replace ():
98
103
if replacements :
99
104
patcher .replace_needed (fn , * replacements )
@@ -113,7 +118,9 @@ def _inner_replace():
113
118
# they may have internal dependencies (DT_NEEDED) on one another, so
114
119
# we need to update those records so each now knows about the new
115
120
# name of the other.
116
- as_completed (copy_works .values ())
121
+ assert all (f .exception () is None for f in as_completed (itertools .chain (
122
+ copy_works .values (), replace_works .values ()
123
+ )))
117
124
for _ , path in soname_map .values ():
118
125
needed = elf_read_dt_needed (path )
119
126
replacements = []
@@ -128,10 +135,10 @@ def _inner_replace():
128
135
129
136
if strip :
130
137
for lib , future in itertools .chain (
131
- copy_works . items (), replace_works . items ()
138
+ [ path for ( _ , path ) in soname_map . values ()], external_refs_by_fn . keys ()
132
139
):
133
140
logger .info ("Stripping symbols from %s" , lib )
134
- then ( future , check_call , ["strip" , "-s" , lib ])
141
+ pool . submit ( check_call , ["strip" , "-s" , lib ])
135
142
136
143
pool .shutdown ()
137
144
@@ -172,7 +179,7 @@ def copylib(
172
179
if dry or dest_path .exists ():
173
180
return new_soname , dest_path
174
181
175
- logger .debug ("Grafting : %s -> %s" , src_path , dest_path )
182
+ logger .debug ("Start grafting : %s -> %s" , src_path , dest_path )
176
183
rpaths = elf_read_rpaths (src_path )
177
184
shutil .copy2 (src_path , dest_path )
178
185
statinfo = dest_path .stat ()
@@ -184,6 +191,8 @@ def copylib(
184
191
if any (itertools .chain (rpaths ["rpaths" ], rpaths ["runpaths" ])):
185
192
patcher .set_rpath (dest_path , "$ORIGIN" )
186
193
194
+ logger .debug ("Done grafting to: %s" , src_path )
195
+
187
196
return new_soname , dest_path
188
197
189
198
0 commit comments