(*args)
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 and Mac OS it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.
With no arguments, return a dictionary of all configuration
    variables relevant for the current platform.
With no arguments return a dictionary of all configuration variables relevant for the current platform .
def get_config_vars(*args):
    """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 and Mac OS it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.
    """
    global _CONFIG_VARS
    if _CONFIG_VARS is None:
        _CONFIG_VARS = {}
        # Normalized versions of prefix and exec_prefix are handy to have;
        # in fact, these are the standard versions used most places in the
        # distutils2 module.
        _CONFIG_VARS['prefix'] = _PREFIX
        _CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX
        _CONFIG_VARS['py_version'] = _PY_VERSION
        _CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
        _CONFIG_VARS['py_version_nodot'] = _PY_VERSION[0] + _PY_VERSION[2]
        _CONFIG_VARS['base'] = _PREFIX
        _CONFIG_VARS['platbase'] = _EXEC_PREFIX
        _CONFIG_VARS['projectbase'] = _PROJECT_BASE
        try:
            _CONFIG_VARS['abiflags'] = sys.abiflags
        except AttributeError:
            # sys.abiflags may not be defined on all platforms.
            _CONFIG_VARS['abiflags'] = ''

        if os.name in ('nt', 'os2'):
            _init_non_posix(_CONFIG_VARS)
        if os.name == 'posix':
            _init_posix(_CONFIG_VARS)
        # Setting 'userbase' is done below the call to the
        # init function to enable using 'get_config_var' in
        # the init-function.
        if sys.version >= '2.6':
            _CONFIG_VARS['userbase'] = _getuserbase()

        if 'srcdir' not in _CONFIG_VARS:
            _CONFIG_VARS['srcdir'] = _PROJECT_BASE
        else:
            _CONFIG_VARS['srcdir'] = _safe_realpath(_CONFIG_VARS['srcdir'])

        # Convert srcdir into an absolute path if it appears necessary.
        # Normally it is relative to the build directory.  However, during
        # testing, for example, we might be running a non-installed python
        # from a different directory.
        if _PYTHON_BUILD and os.name == "posix":
            base = _PROJECT_BASE
            try:
                cwd = os.getcwd()
            except OSError:
                cwd = None
            if (not os.path.isabs(_CONFIG_VARS['srcdir']) and
                base != cwd):
                # srcdir is relative and we are not in the same directory
                # as the executable. Assume executable is in the build
                # directory and make srcdir absolute.
                srcdir = os.path.join(base, _CONFIG_VARS['srcdir'])
                _CONFIG_VARS['srcdir'] = os.path.normpath(srcdir)

        if sys.platform == 'darwin':
            kernel_version = os.uname()[2]  # Kernel version (8.4.3)
            major_version = int(kernel_version.split('.')[0])

            if major_version < 8:
                # On Mac OS X before 10.4, check if -arch and -isysroot
                # are in CFLAGS or LDFLAGS and remove them if they are.
                # This is needed when building extensions on a 10.3 system
                # using a universal build of python.
                for key in ('LDFLAGS', 'BASECFLAGS',
                        # a number of derived variables. These need to be
                        # patched up as well.
                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
                    flags = _CONFIG_VARS[key]
                    flags = re.sub(r'-arch\s+\w+\s', ' ', flags)
                    flags = re.sub('-isysroot [^ \t]*', ' ', flags)
                    _CONFIG_VARS[key] = flags
            else:
                # Allow the user to override the architecture flags using
                # an environment variable.
                # NOTE: This name was introduced by Apple in OSX 10.5 and
                # is used by several scripting languages distributed with
                # that OS release.
                if 'ARCHFLAGS' in os.environ:
                    arch = os.environ['ARCHFLAGS']
                    for key in ('LDFLAGS', 'BASECFLAGS',
                        # a number of derived variables. These need to be
                        # patched up as well.
                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):

                        flags = _CONFIG_VARS[key]
                        flags = re.sub(r'-arch\s+\w+\s', ' ', flags)
                        flags = flags + ' ' + arch
                        _CONFIG_VARS[key] = flags

                # If we're on OSX 10.5 or later and the user tries to
                # compiles an extension using an SDK that is not present
                # on the current machine it is better to not use an SDK
                # than to fail.
                #
                # The major usecase for this is users using a Python.org
                # binary installer  on OSX 10.6: that installer uses
                # the 10.4u SDK, but that SDK is not installed by default
                # when you install Xcode.
                #
                CFLAGS = _CONFIG_VARS.get('CFLAGS', '')
                m = re.search(r'-isysroot\s+(\S+)', CFLAGS)
                if m is not None:
                    sdk = m.group(1)
                    if not os.path.exists(sdk):
                        for key in ('LDFLAGS', 'BASECFLAGS',
                             # a number of derived variables. These need to be
                             # patched up as well.
                            'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):

                            flags = _CONFIG_VARS[key]
                            flags = re.sub(r'-isysroot\s+\S+(\s|$)', ' ', flags)
                            _CONFIG_VARS[key] = flags

    if args:
        vals = []
        for name in args:
            vals.append(_CONFIG_VARS.get(name))
        return vals
    else:
        return _CONFIG_VARS
def get_config_vars ( * args ) : global _CONFIG_VARS if _CONFIG_VARS is None : _CONFIG_VARS = { } # Normalized versions of prefix and exec_prefix are handy to have; # in fact, these are the standard versions used most places in the # distutils2 module. _CONFIG_VARS [ 'prefix' ] = _PREFIX _CONFIG_VARS [ 'exec_prefix' ] = _EXEC_PREFIX _CONFIG_VARS [ 'py_version' ] = _PY_VERSION _CONFIG_VARS [ 'py_version_short' ] = _PY_VERSION_SHORT _CONFIG_VARS [ 'py_version_nodot' ] = _PY_VERSION [ 0 ] + _PY_VERSION [ 2 ] _CONFIG_VARS [ 'base' ] = _PREFIX _CONFIG_VARS [ 'platbase' ] = _EXEC_PREFIX _CONFIG_VARS [ 'projectbase' ] = _PROJECT_BASE try : _CONFIG_VARS [ 'abiflags' ] = sys . abiflags except AttributeError : # sys.abiflags may not be defined on all platforms. _CONFIG_VARS [ 'abiflags' ] = '' if os . name in ( 'nt' , 'os2' ) : _init_non_posix ( _CONFIG_VARS ) if os . name == 'posix' : _init_posix ( _CONFIG_VARS ) # Setting 'userbase' is done below the call to the # init function to enable using 'get_config_var' in # the init-function. if sys . version >= '2.6' : _CONFIG_VARS [ 'userbase' ] = _getuserbase ( ) if 'srcdir' not in _CONFIG_VARS : _CONFIG_VARS [ 'srcdir' ] = _PROJECT_BASE else : _CONFIG_VARS [ 'srcdir' ] = _safe_realpath ( _CONFIG_VARS [ 'srcdir' ] ) # Convert srcdir into an absolute path if it appears necessary. # Normally it is relative to the build directory.  However, during # testing, for example, we might be running a non-installed python # from a different directory. if _PYTHON_BUILD and os . name == "posix" : base = _PROJECT_BASE try : cwd = os . getcwd ( ) except OSError : cwd = None if ( not os . path . isabs ( _CONFIG_VARS [ 'srcdir' ] ) and base != cwd ) : # srcdir is relative and we are not in the same directory # as the executable. Assume executable is in the build # directory and make srcdir absolute. srcdir = os . path . join ( base , _CONFIG_VARS [ 'srcdir' ] ) _CONFIG_VARS [ 'srcdir' ] = os . path . normpath ( srcdir ) if sys . platform == 'darwin' : kernel_version = os . uname ( ) [ 2 ] # Kernel version (8.4.3) major_version = int ( kernel_version . split ( '.' ) [ 0 ] ) if major_version < 8 : # On Mac OS X before 10.4, check if -arch and -isysroot # are in CFLAGS or LDFLAGS and remove them if they are. # This is needed when building extensions on a 10.3 system # using a universal build of python. for key in ( 'LDFLAGS' , 'BASECFLAGS' , # a number of derived variables. These need to be # patched up as well. 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ) : flags = _CONFIG_VARS [ key ] flags = re . sub ( r'-arch\s+\w+\s' , ' ' , flags ) flags = re . sub ( '-isysroot [^ \t]*' , ' ' , flags ) _CONFIG_VARS [ key ] = flags else : # Allow the user to override the architecture flags using # an environment variable. # NOTE: This name was introduced by Apple in OSX 10.5 and # is used by several scripting languages distributed with # that OS release. if 'ARCHFLAGS' in os . environ : arch = os . environ [ 'ARCHFLAGS' ] for key in ( 'LDFLAGS' , 'BASECFLAGS' , # a number of derived variables. These need to be # patched up as well. 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ) : flags = _CONFIG_VARS [ key ] flags = re . sub ( r'-arch\s+\w+\s' , ' ' , flags ) flags = flags + ' ' + arch _CONFIG_VARS [ key ] = flags # If we're on OSX 10.5 or later and the user tries to # compiles an extension using an SDK that is not present # on the current machine it is better to not use an SDK # than to fail. # # The major usecase for this is users using a Python.org # binary installer  on OSX 10.6: that installer uses # the 10.4u SDK, but that SDK is not installed by default # when you install Xcode. # CFLAGS = _CONFIG_VARS . get ( 'CFLAGS' , '' ) m = re . search ( r'-isysroot\s+(\S+)' , CFLAGS ) if m is not None : sdk = m . group ( 1 ) if not os . path . exists ( sdk ) : for key in ( 'LDFLAGS' , 'BASECFLAGS' , # a number of derived variables. These need to be # patched up as well. 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ) : flags = _CONFIG_VARS [ key ] flags = re . sub ( r'-isysroot\s+\S+(\s|$)' , ' ' , flags ) _CONFIG_VARS [ key ] = flags if args : vals = [ ] for name in args : vals . append ( _CONFIG_VARS . get ( name ) ) return vals else : return _CONFIG_VARS