Skip to content

Commit 11e880d

Browse files
authored
Merge pull request #20222 from QuLogic/fix-c-coverage
Fix C coverage
2 parents c5d7ce2 + d5407ce commit 11e880d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,20 @@ def build_extensions(self):
192192
package.do_custom_build(env)
193193
return super().build_extensions()
194194

195+
def build_extension(self, ext):
196+
# When C coverage is enabled, the path to the object file is saved.
197+
# Since we re-use source files in multiple extensions, libgcov will
198+
# complain at runtime that it is trying to save coverage for the same
199+
# object file at different timestamps (since each source is compiled
200+
# again for each extension). Thus, we need to use unique temporary
201+
# build directories to store object files for each extension.
202+
orig_build_temp = self.build_temp
203+
self.build_temp = os.path.join(self.build_temp, ext.name)
204+
try:
205+
super().build_extension(ext)
206+
finally:
207+
self.build_temp = orig_build_temp
208+
195209

196210
def update_matplotlibrc(path):
197211
# If packagers want to change the default backend, insert a `#backend: ...`

0 commit comments

Comments
 (0)