aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorDaniele Nicolodi <daniele@grinta.net>2022-10-27 11:02:00 +0200
committerEli Schwartz <eschwartz93@gmail.com>2022-11-23 07:29:23 -0500
commit235f32f1a67f1d6662b0b1da08621e587da89f72 (patch)
treec2d4c66de43e236a7dfcbbd86df521e7c1f11d7a /mesonbuild/modules
parent0404ad5601418884f967f8917cbf763cfb7be282 (diff)
downloadmeson-235f32f1a67f1d6662b0b1da08621e587da89f72.zip
meson-235f32f1a67f1d6662b0b1da08621e587da89f72.tar.gz
meson-235f32f1a67f1d6662b0b1da08621e587da89f72.tar.bz2
python: Use correct extension filename suffix on Python < 3.8.7
On Windows, in Python version prior to 3.8.7, the `sysconfig` modules provides an extension filename suffix that disagrees the one returned by `distutils.sysconfig`. Get the more awesome suffix from the latter when building for a Python version known to present this issue. Simplify the extension module filename suffix lookup to use the same method used by `setuptools`. Adjust project tests accordingly. Fixes #10960.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/python.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 84ec524..98808c4 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -372,6 +372,15 @@ def links_against_libpython():
variables = sysconfig.get_config_vars()
variables.update({'base_prefix': getattr(sys, 'base_prefix', sys.prefix)})
+if sys.version_info < (3, 0):
+ suffix = variables.get('SO')
+elif sys.version_info < (3, 8, 7):
+ # https://bugs.python.org/issue?@action=redirect&bpo=39825
+ from distutils.sysconfig import get_config_var
+ suffix = get_config_var('EXT_SUFFIX')
+else:
+ suffix = variables.get('EXT_SUFFIX')
+
print(json.dumps({
'variables': variables,
'paths': paths,
@@ -382,6 +391,7 @@ print(json.dumps({
'is_pypy': '__pypy__' in sys.builtin_module_names,
'is_venv': sys.prefix != variables['base_prefix'],
'link_libpython': links_against_libpython(),
+ 'suffix': suffix,
}))
'''
@@ -440,8 +450,6 @@ class PythonExternalProgram(ExternalProgram):
mlog.debug(stderr)
if info is not None and self._check_version(info['version']):
- variables = info['variables']
- info['suffix'] = variables.get('EXT_SUFFIX') or variables.get('SO') or variables.get('.so')
self.info = T.cast('PythonIntrospectionDict', info)
self.platlib = self._get_path(state, 'platlib')
self.purelib = self._get_path(state, 'purelib')