Skip to content

Commit 853d0f5

Browse files
committed
Extract a method for customizing the compiler for macOS.
1 parent 073eb37 commit 853d0f5

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

distutils/sysconfig.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,29 +266,35 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
266266
)
267267

268268

269+
def _customize_macos():
270+
if sys.platform != "darwin":
271+
return
272+
273+
# Perform first-time customization of compiler-related
274+
# config vars on OS X now that we know we need a compiler.
275+
# This is primarily to support Pythons from binary
276+
# 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+
global _config_vars
282+
# Use get_config_var() to ensure _config_vars is initialized.
283+
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
284+
import _osx_support
285+
286+
_osx_support.customize_compiler(_config_vars)
287+
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
288+
289+
269290
def customize_compiler(compiler): # noqa: C901
270291
"""Do any platform-specific customization of a CCompiler instance.
271292
272293
Mainly needed on Unix, so we can plug in the information that
273294
varies across Unices and is stored in Python's Makefile.
274295
"""
275296
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'
297+
_customize_macos()
292298

293299
(
294300
cc,

0 commit comments

Comments
 (0)