From d5407ce56a09a949896957297a540c722c213b21 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 13 May 2021 21:10:44 -0400 Subject: [PATCH] Save extension build objects in unique directories. When C coverage is enabled, the path to the object file is saved. Since we re-use source files in multiple extensions, libgcov will complain at runtime that it is trying to save coverage for the same object file at different timestamps (since each source is compiled again for each extension). Thus, we need to use unique temporary build directories to store object files for each extension. --- setup.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setup.py b/setup.py index 4caee372af08..657f34e8feab 100644 --- a/setup.py +++ b/setup.py @@ -192,6 +192,20 @@ def build_extensions(self): package.do_custom_build(env) return super().build_extensions() + def build_extension(self, ext): + # When C coverage is enabled, the path to the object file is saved. + # Since we re-use source files in multiple extensions, libgcov will + # complain at runtime that it is trying to save coverage for the same + # object file at different timestamps (since each source is compiled + # again for each extension). Thus, we need to use unique temporary + # build directories to store object files for each extension. + orig_build_temp = self.build_temp + self.build_temp = os.path.join(self.build_temp, ext.name) + try: + super().build_extension(ext) + finally: + self.build_temp = orig_build_temp + def update_matplotlibrc(path): # If packagers want to change the default backend, insert a `#backend: ...`