bpo-39825: Fixes sysconfig.get_config_var('EXT_SUFFIX') on Windows to match distutils (GH-22088)

This commit is contained in:
Matti Picus 2020-12-07 19:33:20 +02:00 committed by GitHub
parent 0ef96c2b2a
commit c0afb7fa0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -424,10 +424,11 @@ def _init_posix(vars):
def _init_non_posix(vars): def _init_non_posix(vars):
"""Initialize the module as appropriate for NT""" """Initialize the module as appropriate for NT"""
# set basic install directories # set basic install directories
import _imp
vars['LIBDEST'] = get_path('stdlib') vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib') vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include') vars['INCLUDEPY'] = get_path('include')
vars['EXT_SUFFIX'] = '.pyd' vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
vars['EXE'] = '.exe' vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))

View File

@ -360,10 +360,12 @@ class TestSysConfig(unittest.TestCase):
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None, @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
'EXT_SUFFIX required for this test') 'EXT_SUFFIX required for this test')
def test_SO_in_vars(self): def test_EXT_SUFFIX_in_vars(self):
import _imp
vars = sysconfig.get_config_vars() vars = sysconfig.get_config_vars()
self.assertIsNotNone(vars['SO']) self.assertIsNotNone(vars['SO'])
self.assertEqual(vars['SO'], vars['EXT_SUFFIX']) self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
@unittest.skipUnless(sys.platform == 'linux' and @unittest.skipUnless(sys.platform == 'linux' and
hasattr(sys.implementation, '_multiarch'), hasattr(sys.implementation, '_multiarch'),

View File

@ -0,0 +1,5 @@
Windows: Change ``sysconfig.get_config_var('EXT_SUFFIX')`` to the expected
full ``platform_tag.extension`` format. Previously it was hard-coded to
``.pyd``, now it is compatible with ``distutils.sysconfig`` and will result
in something like ``.cp38-win_amd64.pyd``. This brings windows into
conformance with the other platforms.