MCPcopy Index your code
hub / github.com/python/cpython / get_config_vars

Function get_config_vars

Lib/sysconfig/__init__.py:589–626  ·  view source on GitHub ↗

With no arguments, return a dictionary of all configuration variables relevant for the current platform. On Unix, this means every variable defined in Python's installed Makefile; On Windows it's a much smaller set. With arguments, return a list of values that result from looking u

(*args)

Source from the content-addressed store, hash-verified

587
588
589def get_config_vars(*args):
590 """With no arguments, return a dictionary of all configuration
591 variables relevant for the current platform.
592
593 On Unix, this means every variable defined in Python's installed Makefile;
594 On Windows it's a much smaller set.
595
596 With arguments, return a list of values that result from looking up
597 each argument in the configuration variable dictionary.
598 """
599 global _CONFIG_VARS_INITIALIZED
600
601 # Avoid claiming the lock once initialization is complete.
602 if _CONFIG_VARS_INITIALIZED:
603 # GH-126789: If sys.prefix or sys.exec_prefix were updated, invalidate the cache.
604 prefix = os.path.normpath(sys.prefix)
605 exec_prefix = os.path.normpath(sys.exec_prefix)
606 if _CONFIG_VARS['prefix'] != prefix or _CONFIG_VARS['exec_prefix'] != exec_prefix:
607 with _CONFIG_VARS_LOCK:
608 _CONFIG_VARS_INITIALIZED = False
609 _init_config_vars()
610 else:
611 # Initialize the config_vars cache.
612 with _CONFIG_VARS_LOCK:
613 # Test again with the lock held to avoid races. Note that
614 # we test _CONFIG_VARS here, not _CONFIG_VARS_INITIALIZED,
615 # to ensure that recursive calls to get_config_vars()
616 # don't re-enter init_config_vars().
617 if _CONFIG_VARS is None:
618 _init_config_vars()
619
620 if args:
621 vals = []
622 for name in args:
623 vals.append(_CONFIG_VARS.get(name))
624 return vals
625 else:
626 return _CONFIG_VARS
627
628
629def get_config_var(name):

Callers 9

_generate_posix_varsFunction · 0.90
_mainFunction · 0.90
test_get_pathMethod · 0.90
test_get_config_varsMethod · 0.90
test_get_platformMethod · 0.90
_expand_varsFunction · 0.85
get_config_varFunction · 0.85
get_platformFunction · 0.85

Calls 3

_init_config_varsFunction · 0.85
appendMethod · 0.45
getMethod · 0.45

Tested by 4

test_get_pathMethod · 0.72
test_get_config_varsMethod · 0.72
test_get_platformMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…