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)
| 587 | |
| 588 | |
| 589 | def 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 | |
| 629 | def get_config_var(name): |
searching dependent graphs…