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 loo
(*args)
| 627 | |
| 628 | |
| 629 | def get_config_vars(*args): |
| 630 | """With no arguments, return a dictionary of all configuration |
| 631 | variables relevant for the current platform. |
| 632 | |
| 633 | On Unix, this means every variable defined in Python's installed Makefile; |
| 634 | On Windows it's a much smaller set. |
| 635 | |
| 636 | With arguments, return a list of values that result from looking up |
| 637 | each argument in the configuration variable dictionary. |
| 638 | """ |
| 639 | global _CONFIG_VARS |
| 640 | if _CONFIG_VARS is None: |
| 641 | _CONFIG_VARS = {} |
| 642 | # Normalized versions of prefix and exec_prefix are handy to have; |
| 643 | # in fact, these are the standard versions used most places in the |
| 644 | # Distutils. |
| 645 | _CONFIG_VARS['prefix'] = _PREFIX |
| 646 | _CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX |
| 647 | _CONFIG_VARS['py_version'] = _PY_VERSION |
| 648 | _CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT |
| 649 | _CONFIG_VARS['py_version_nodot'] = _PY_VERSION_SHORT_NO_DOT |
| 650 | _CONFIG_VARS['installed_base'] = _BASE_PREFIX |
| 651 | _CONFIG_VARS['base'] = _PREFIX |
| 652 | _CONFIG_VARS['installed_platbase'] = _BASE_EXEC_PREFIX |
| 653 | _CONFIG_VARS['platbase'] = _EXEC_PREFIX |
| 654 | _CONFIG_VARS['projectbase'] = _PROJECT_BASE |
| 655 | _CONFIG_VARS['platlibdir'] = sys.platlibdir |
| 656 | try: |
| 657 | _CONFIG_VARS['abiflags'] = sys.abiflags |
| 658 | except AttributeError: |
| 659 | # sys.abiflags may not be defined on all platforms. |
| 660 | _CONFIG_VARS['abiflags'] = '' |
| 661 | try: |
| 662 | _CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '') |
| 663 | except AttributeError: |
| 664 | _CONFIG_VARS['py_version_nodot_plat'] = '' |
| 665 | |
| 666 | if os.name == 'nt': |
| 667 | _init_non_posix(_CONFIG_VARS) |
| 668 | _CONFIG_VARS['VPATH'] = sys._vpath |
| 669 | if os.name == 'posix': |
| 670 | _init_posix(_CONFIG_VARS) |
| 671 | if _HAS_USER_BASE: |
| 672 | # Setting 'userbase' is done below the call to the |
| 673 | # init function to enable using 'get_config_var' in |
| 674 | # the init-function. |
| 675 | _CONFIG_VARS['userbase'] = _getuserbase() |
| 676 | |
| 677 | # Always convert srcdir to an absolute path |
| 678 | srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE) |
| 679 | if os.name == 'posix': |
| 680 | if _PYTHON_BUILD: |
| 681 | # If srcdir is a relative path (typically '.' or '..') |
| 682 | # then it should be interpreted relative to the directory |
| 683 | # containing Makefile. |
| 684 | base = os.path.dirname(get_makefile_filename()) |
| 685 | srcdir = os.path.join(base, srcdir) |
| 686 | else: |
no test coverage detected