Skip to content

Commit 9e83319

Browse files
committed
Limit mutating global state and simply rely on functools.lru_cache to limit the behavior to a single invocation.
1 parent cc455d0 commit 9e83319

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

distutils/sysconfig.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111

1212
import os
13+
import functools
1314
import re
1415
import sys
1516
import sysconfig
@@ -266,6 +267,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
266267
)
267268

268269

270+
@functools.lru_cache()
269271
def _customize_macos():
270272
"""
271273
Perform first-time customization of compiler-related
@@ -278,16 +280,9 @@ def _customize_macos():
278280
of CPU architectures for universal builds.
279281
"""
280282

281-
if sys.platform != "darwin":
282-
return
283-
284-
global _config_vars
285-
# Use get_config_var() to ensure _config_vars is initialized.
286-
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
287-
import _osx_support
288-
289-
_osx_support.customize_compiler(_config_vars)
290-
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
283+
sys.platform == "darwin" and __import__('_osx_support').customize_compiler(
284+
get_config_vars()
285+
)
291286

292287

293288
def customize_compiler(compiler): # noqa: C901

0 commit comments

Comments
 (0)