@@ -173,9 +173,6 @@ def joinuser(*args):
173173_SCHEME_KEYS = ('stdlib' , 'platstdlib' , 'purelib' , 'platlib' , 'include' ,
174174 'scripts' , 'data' )
175175
176- _PY_VERSION = _sysconfig .PY_VERSION
177- _PY_VERSION_SHORT = f'{ sys .version_info [0 ]} .{ sys .version_info [1 ]} '
178- _PY_VERSION_SHORT_NO_DOT = f'{ sys .version_info [0 ]} { sys .version_info [1 ]} '
179176_BASE_PREFIX = os .path .normpath (sys .base_prefix )
180177_BASE_EXEC_PREFIX = os .path .normpath (sys .base_exec_prefix )
181178# Mutex guarding initialization of _CONFIG_VARS.
@@ -324,7 +321,8 @@ def get_makefile_filename():
324321 return os .path .join (_PROJECT_BASE , "Makefile" )
325322
326323 if hasattr (sys , 'abiflags' ):
327- config_dir_name = f'config-{ _PY_VERSION_SHORT } { sys .abiflags } '
324+ py_version_short = f'{ sys .version_info [0 ]} .{ sys .version_info [1 ]} '
325+ config_dir_name = f'config-{ py_version_short } { sys .abiflags } '
328326 else :
329327 config_dir_name = 'config'
330328
@@ -390,9 +388,6 @@ def _init_non_posix(vars):
390388 vars ['BINLIBDEST' ] = get_path ('platstdlib' )
391389 vars ['INCLUDEPY' ] = get_path ('include' )
392390
393- # Add EXT_SUFFIX, SOABI, Py_DEBUG, and Py_GIL_DISABLED
394- vars .update (_sysconfig .config_vars ())
395-
396391 # NOTE: ABIFLAGS is only an emulated value. It is not present during build
397392 # on Windows. sys.abiflags is absent on Windows and vars['abiflags']
398393 # is already widely used to calculate paths, so it should remain an
@@ -410,7 +405,7 @@ def _init_non_posix(vars):
410405 vars ['LIBRARY' ] = os .path .basename (_safe_realpath (dllhandle ))
411406 vars ['LDLIBRARY' ] = vars ['LIBRARY' ]
412407 vars ['EXE' ] = '.exe'
413- vars ['VERSION' ] = _PY_VERSION_SHORT_NO_DOT
408+ vars ['VERSION' ] = vars [ 'py_version_nodot' ]
414409 vars ['BINDIR' ] = os .path .dirname (_safe_realpath (sys .executable ))
415410 # No standard path exists on Windows for this, but we'll check
416411 # whether someone is imitating a POSIX-like layout
@@ -505,6 +500,10 @@ def _init_config_vars():
505500 global _CONFIG_VARS
506501 _CONFIG_VARS = {}
507502
503+ # Add py_version, Py_DEBUG, and Py_GIL_DISABLED.
504+ # On Windows, add also EXT_SUFFIX and SOABI.
505+ _CONFIG_VARS .update (_sysconfig .config_vars ())
506+
508507 prefix = os .path .normpath (sys .prefix )
509508 exec_prefix = os .path .normpath (sys .exec_prefix )
510509 base_prefix = _BASE_PREFIX
@@ -530,9 +529,6 @@ def _init_config_vars():
530529 # Distutils.
531530 _CONFIG_VARS ['prefix' ] = prefix
532531 _CONFIG_VARS ['exec_prefix' ] = exec_prefix
533- _CONFIG_VARS ['py_version' ] = _PY_VERSION
534- _CONFIG_VARS ['py_version_short' ] = _PY_VERSION_SHORT
535- _CONFIG_VARS ['py_version_nodot' ] = _PY_VERSION_SHORT_NO_DOT
536532 _CONFIG_VARS ['installed_base' ] = base_prefix
537533 _CONFIG_VARS ['base' ] = prefix
538534 _CONFIG_VARS ['installed_platbase' ] = base_exec_prefix
@@ -739,11 +735,11 @@ def get_platform():
739735
740736
741737def get_python_version ():
742- return _PY_VERSION_SHORT
738+ return get_config_var ( 'py_version_short' )
743739
744740
745741def _get_python_version_abi ():
746- return _PY_VERSION_SHORT + get_config_var ("abi_thread" )
742+ return get_config_var ( 'py_version_short' ) + get_config_var ("abi_thread" )
747743
748744
749745def expand_makefile_vars (s , vars ):
0 commit comments