|
10 | 10 | """
|
11 | 11 |
|
12 | 12 | import os
|
| 13 | +import functools |
13 | 14 | import re
|
14 | 15 | import sys
|
15 | 16 | import sysconfig
|
@@ -266,29 +267,32 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
266 | 267 | )
|
267 | 268 |
|
268 | 269 |
|
| 270 | +@functools.lru_cache() |
| 271 | +def _customize_macos(): |
| 272 | + """ |
| 273 | + Perform first-time customization of compiler-related |
| 274 | + config vars on macOS. Use after a compiler is known |
| 275 | + to be needed. This customization exists primarily to support Pythons |
| 276 | + from binary installers. The kind and paths to build tools on |
| 277 | + the user system may vary significantly from the system |
| 278 | + that Python itself was built on. Also the user OS |
| 279 | + version and build tools may not support the same set |
| 280 | + of CPU architectures for universal builds. |
| 281 | + """ |
| 282 | + |
| 283 | + sys.platform == "darwin" and __import__('_osx_support').customize_compiler( |
| 284 | + get_config_vars() |
| 285 | + ) |
| 286 | + |
| 287 | + |
269 | 288 | def customize_compiler(compiler): # noqa: C901
|
270 | 289 | """Do any platform-specific customization of a CCompiler instance.
|
271 | 290 |
|
272 | 291 | Mainly needed on Unix, so we can plug in the information that
|
273 | 292 | varies across Unices and is stored in Python's Makefile.
|
274 | 293 | """
|
275 | 294 | if compiler.compiler_type == "unix":
|
276 |
| - if sys.platform == "darwin": |
277 |
| - # Perform first-time customization of compiler-related |
278 |
| - # config vars on OS X now that we know we need a compiler. |
279 |
| - # This is primarily to support Pythons from binary |
280 |
| - # installers. The kind and paths to build tools on |
281 |
| - # the user system may vary significantly from the system |
282 |
| - # that Python itself was built on. Also the user OS |
283 |
| - # version and build tools may not support the same set |
284 |
| - # of CPU architectures for universal builds. |
285 |
| - global _config_vars |
286 |
| - # Use get_config_var() to ensure _config_vars is initialized. |
287 |
| - if not get_config_var('CUSTOMIZED_OSX_COMPILER'): |
288 |
| - import _osx_support |
289 |
| - |
290 |
| - _osx_support.customize_compiler(_config_vars) |
291 |
| - _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' |
| 295 | + _customize_macos() |
292 | 296 |
|
293 | 297 | (
|
294 | 298 | cc,
|
|
0 commit comments