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

zooba webhook-mailer at python.org
Mon Dec 7 12:33:37 EST 2020


https://github.com/python/cpython/commit/c0afb7fa0ebd1c0e95c0760bbe75a99a8dd12ea6
commit: c0afb7fa0ebd1c0e95c0760bbe75a99a8dd12ea6
branch: master
author: Matti Picus <matti.picus at gmail.com>
committer: zooba <steve.dower at microsoft.com>
date: 2020-12-07T17:33:20Z
summary:

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

files:
A Misc/NEWS.d/next/Library/2020-10-20-08-28-26.bpo-39825.n6KnG0.rst
M Lib/sysconfig.py
M Lib/test/test_sysconfig.py

diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 6c87b06634c45..e1b2f93f876d7 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -424,10 +424,11 @@ def _init_posix(vars):
 def _init_non_posix(vars):
     """Initialize the module as appropriate for NT"""
     # set basic install directories
+    import _imp
     vars['LIBDEST'] = get_path('stdlib')
     vars['BINLIBDEST'] = get_path('platstdlib')
     vars['INCLUDEPY'] = get_path('include')
-    vars['EXT_SUFFIX'] = '.pyd'
+    vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
     vars['EXE'] = '.exe'
     vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
     vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index d07d28df607ce..352dbdea817e6 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -360,10 +360,12 @@ def test_SO_value(self):
 
     @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
                      '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()
         self.assertIsNotNone(vars['SO'])
         self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
+        self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
 
     @unittest.skipUnless(sys.platform == 'linux' and
                          hasattr(sys.implementation, '_multiarch'),
diff --git a/Misc/NEWS.d/next/Library/2020-10-20-08-28-26.bpo-39825.n6KnG0.rst b/Misc/NEWS.d/next/Library/2020-10-20-08-28-26.bpo-39825.n6KnG0.rst
new file mode 100644
index 0000000000000..c337731f43584
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-20-08-28-26.bpo-39825.n6KnG0.rst
@@ -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.



More information about the Python-checkins mailing list