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