Skip to content

Commit d735baf

Browse files
eli-schwartzrobtaylor
authored andcommitted
python module: refactor pypy detection into a consistent variable
1 parent d53d10b commit d735baf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mesonbuild/scripts/python_info.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def links_against_libpython():
7272
variables = sysconfig.get_config_vars()
7373
variables.update({'base_prefix': getattr(sys, 'base_prefix', sys.prefix)})
7474

75+
is_pypy = '__pypy__' in sys.builtin_module_names
76+
7577
if sys.version_info < (3, 0):
7678
suffix = variables.get('SO')
7779
elif sys.version_info < (3, 8, 7):
@@ -92,7 +94,7 @@ def links_against_libpython():
9294
# pypy supports modules targetting the limited api but
9395
# does not use a special suffix to distinguish them:
9496
# https://doc.pypy.org/en/latest/cpython_differences.html#permitted-abi-tags-in-extensions
95-
if '__pypy__' in sys.builtin_module_names:
97+
if is_pypy:
9698
limited_api_suffix = suffix
9799

98100
print(json.dumps({
@@ -102,7 +104,7 @@ def links_against_libpython():
102104
'install_paths': install_paths,
103105
'version': sysconfig.get_python_version(),
104106
'platform': sysconfig.get_platform(),
105-
'is_pypy': '__pypy__' in sys.builtin_module_names,
107+
'is_pypy': is_pypy,
106108
'is_venv': sys.prefix != variables['base_prefix'],
107109
'link_libpython': links_against_libpython(),
108110
'suffix': suffix,

0 commit comments

Comments
 (0)