@@ -319,9 +319,11 @@ def get_makefile_filename():
319319 config_dir_name = 'config'
320320 return os .path .join (get_path ('stdlib' ), config_dir_name , 'Makefile' )
321321
322-
323- def _init_posix (vars ):
324- """Initialize the module as appropriate for POSIX systems."""
322+ def _generate_posix_vars ():
323+ """Generate the Python module containing build-time variables."""
324+ import pprint
325+ vars = {}
326+ destfile = os .path .join (os .path .dirname (__file__ ), '_sysconfigdata.py' )
325327 # load the installed Makefile:
326328 makefile = get_makefile_filename ()
327329 try :
@@ -346,7 +348,15 @@ def _init_posix(vars):
346348 # the scripts are in another directory.
347349 if _PYTHON_BUILD :
348350 vars ['LDSHARED' ] = vars ['BLDSHARED' ]
351+ with open (destfile , 'w' , encoding = 'utf8' ) as f :
352+ f .write ('build_time_vars = ' )
353+ pprint .pprint (vars , stream = f )
349354
355+ def _init_posix (vars ):
356+ """Initialize the module as appropriate for POSIX systems."""
357+ # _sysconfigdata is generated at build time, see _generate_posix_vars()
358+ from _sysconfigdata import build_time_vars
359+ vars .update (build_time_vars )
350360
351361def _init_non_posix (vars ):
352362 """Initialize the module as appropriate for NT"""
@@ -753,6 +763,9 @@ def _print_dict(title, data):
753763
754764def _main ():
755765 """Display all information sysconfig detains."""
766+ if '--generate-posix-vars' in sys .argv :
767+ _generate_posix_vars ()
768+ return
756769 print ('Platform: "%s"' % get_platform ())
757770 print ('Python version: "%s"' % get_python_version ())
758771 print ('Current installation scheme: "%s"' % _get_default_scheme ())
0 commit comments