Skip to content

Commit

Permalink
Limit mutating global state and simply rely on functools.lru_cache to…
Browse files Browse the repository at this point in the history
… limit the behavior to a single invocation.
  • Loading branch information
jaraco committed Mar 2, 2024
1 parent 6c43552 commit b853cc3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import os
import functools
import re
import sys
import sysconfig
Expand Down Expand Up @@ -266,6 +267,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
)


@functools.lru_cache()
def _customize_macos():
"""
Perform first-time customization of compiler-related
Expand All @@ -278,16 +280,9 @@ def _customize_macos():
of CPU architectures for universal builds.
"""

if sys.platform != "darwin":
return

global _config_vars
# Use get_config_var() to ensure _config_vars is initialized.
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
import _osx_support

_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
sys.platform == "darwin" and __import__('_osx_support').customize_compiler(
get_config_vars()
)


def customize_compiler(compiler): # noqa: C901
Expand Down

0 comments on commit b853cc3

Please sign in to comment.