@@ -73,7 +73,48 @@ def is_platform_mac():
73
73
_pxi_dep [module ] = pxi_files
74
74
75
75
76
- class build_ext (_build_ext ):
76
+ class CompilerLauncherMixin :
77
+ """Add "compiler launchers" to distutils.
78
+
79
+ We use this to be able to run the Pandas build using "ccache".
80
+
81
+ A compiler launcher is a program that is invoked instead of invoking the
82
+ compiler directly. It is passed the full compiler invocation command line.
83
+
84
+ A similar feature exists in CMake, see
85
+ https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html.
86
+ """
87
+
88
+ __is_set_up = False
89
+
90
+ def build_extensions (self ):
91
+ # Integrate into "build_ext"
92
+ self .__setup ()
93
+ super ().build_extensions ()
94
+
95
+ def build_libraries (self ):
96
+ # Integrate into "build_clib"
97
+ self .__setup ()
98
+ super ().build_extensions ()
99
+
100
+ def __setup (self ):
101
+ if self .__is_set_up :
102
+ return
103
+ self .__is_set_up = True
104
+ compiler_launcher = os .getenv ("DISTUTILS_C_COMPILER_LAUNCHER" )
105
+ if compiler_launcher :
106
+
107
+ def spawn_with_compiler_launcher (cmd ):
108
+ exclude_programs = ("link.exe" ,)
109
+ if not cmd [0 ].endswith (exclude_programs ):
110
+ cmd = [compiler_launcher ] + cmd
111
+ return original_spawn (cmd )
112
+
113
+ original_spawn = self .compiler .spawn
114
+ self .compiler .spawn = spawn_with_compiler_launcher
115
+
116
+
117
+ class build_ext (CompilerLauncherMixin , _build_ext ):
77
118
@classmethod
78
119
def render_templates (cls , pxifiles ):
79
120
for pxifile in pxifiles :
0 commit comments