parameters: ()
docstring: Generate the Python module containing build-time variables.
docstring_summary: Generate the Python module containing build-time variables.
docstring_tokens: Generate the Python module containing build - time variables .
function: def _generate_posix_vars():
      """Generate the Python module containing build-time variables."""
      import pprint
      vars = {}
      # load the installed Makefile:
      makefile = get_makefile_filename()
      try:
          _parse_makefile(makefile, vars)
      except OSError as e:
          msg = "invalid Python installation: unable to open %s" % makefile
          if hasattr(e, "strerror"):
              msg = msg + " (%s)" % e.strerror
          raise OSError(msg)
      # load the installed pyconfig.h:
      config_h = get_config_h_filename()
      try:
          with open(config_h) as f:
              parse_config_h(f, vars)
      except OSError as e:
          msg = "invalid Python installation: unable to open %s" % config_h
          if hasattr(e, "strerror"):
              msg = msg + " (%s)" % e.strerror
          raise OSError(msg)
      # On AIX, there are wrong paths to the linker scripts in the Makefile
      # -- these paths are relative to the Python source, but when installed
      # the scripts are in another directory.
      if _PYTHON_BUILD:
          vars['BLDSHARED'] = vars['LDSHARED']
  
      # There's a chicken-and-egg situation on OS X with regards to the
      # _sysconfigdata module after the changes introduced by #15298:
      # get_config_vars() is called by get_platform() as part of the
      # `make pybuilddir.txt` target -- which is a precursor to the
      # _sysconfigdata.py module being constructed.  Unfortunately,
      # get_config_vars() eventually calls _init_posix(), which attempts
      # to import _sysconfigdata, which we won't have built yet.  In order
      # for _init_posix() to work, if we're on Darwin, just mock up the
      # _sysconfigdata module manually and populate it with the build vars.
      # This is more than sufficient for ensuring the subsequent call to
      # get_platform() succeeds.
      name = _get_sysconfigdata_name()
      if 'darwin' in sys.platform:
          import types
          module = types.ModuleType(name)
          module.build_time_vars = vars
          sys.modules[name] = module
  
      pybuilddir = 'build/lib.%s-%s' % (get_platform(), _PY_VERSION_SHORT)
      if hasattr(sys, "gettotalrefcount"):
          pybuilddir += '-pydebug'
      os.makedirs(pybuilddir, exist_ok=True)
      destfile = os.path.join(pybuilddir, name + '.py')
  
      with open(destfile, 'w', encoding='utf8') as f:
          f.write('# system configuration generated and used by'
                  ' the sysconfig module\n')
          f.write('build_time_vars = ')
          pprint.pprint(vars, stream=f)
  
      # Create file used for sys.path fixup -- see Modules/getpath.c
      with open('pybuilddir.txt', 'w', encoding='ascii') as f:
          f.write(pybuilddir)
function_tokens: def _generate_posix_vars ( ) : import pprint vars = { } # load the installed Makefile: makefile = get_makefile_filename ( ) try : _parse_makefile ( makefile , vars ) except OSError as e : msg = "invalid Python installation: unable to open %s" % makefile if hasattr ( e , "strerror" ) : msg = msg + " (%s)" % e . strerror raise OSError ( msg ) # load the installed pyconfig.h: config_h = get_config_h_filename ( ) try : with open ( config_h ) as f : parse_config_h ( f , vars ) except OSError as e : msg = "invalid Python installation: unable to open %s" % config_h if hasattr ( e , "strerror" ) : msg = msg + " (%s)" % e . strerror raise OSError ( msg ) # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if _PYTHON_BUILD : vars [ 'BLDSHARED' ] = vars [ 'LDSHARED' ] # There's a chicken-and-egg situation on OS X with regards to the # _sysconfigdata module after the changes introduced by #15298: # get_config_vars() is called by get_platform() as part of the # `make pybuilddir.txt` target -- which is a precursor to the # _sysconfigdata.py module being constructed.  Unfortunately, # get_config_vars() eventually calls _init_posix(), which attempts # to import _sysconfigdata, which we won't have built yet.  In order # for _init_posix() to work, if we're on Darwin, just mock up the # _sysconfigdata module manually and populate it with the build vars. # This is more than sufficient for ensuring the subsequent call to # get_platform() succeeds. name = _get_sysconfigdata_name ( ) if 'darwin' in sys . platform : import types module = types . ModuleType ( name ) module . build_time_vars = vars sys . modules [ name ] = module pybuilddir = 'build/lib.%s-%s' % ( get_platform ( ) , _PY_VERSION_SHORT ) if hasattr ( sys , "gettotalrefcount" ) : pybuilddir += '-pydebug' os . makedirs ( pybuilddir , exist_ok = True ) destfile = os . path . join ( pybuilddir , name + '.py' ) with open ( destfile , 'w' , encoding = 'utf8' ) as f : f . write ( '# system configuration generated and used by' ' the sysconfig module\n' ) f . write ( 'build_time_vars = ' ) pprint . pprint ( vars , stream = f ) # Create file used for sys.path fixup -- see Modules/getpath.c with open ( 'pybuilddir.txt' , 'w' , encoding = 'ascii' ) as f : f . write ( pybuilddir )