Skip to content

Commit a86ffc0

Browse files
committed
python: Restore the previous logic for missing pkg-config dir
Restore the previous logic that skipped pkg-config lookup when the implementation did not specify a pkg-config directory. Previously it applied to `LIBPC` sysconfig variable only, so extend it to missing `c_api.pkgconfig_path` PEP 739 key. The fallback introduced previously could result in pkg-config files for a different installation being used, particularly we could end up using CPython's pkg-config files for PyPy.
1 parent 5601f5a commit a86ffc0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mesonbuild/dependencies/python.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,12 @@ def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any],
455455
pkg_libdir = installation.info['variables'].get('LIBPC')
456456
pkg_libdir_origin = 'LIBPC'
457457
if pkg_libdir is None:
458-
pkg_libdir_origin = 'the default paths'
458+
# we do not fall back to system directories, since this could lead
459+
# to using pkg-config of another Python installation, for example
460+
# we could end up using CPython .pc file for PyPy
461+
mlog.debug(f'Skipping pkgconfig lookup, {pkg_libdir_origin} is unset')
462+
self.is_found = False
463+
return
459464
mlog.debug(f'Searching for {pkg_libdir!r} via pkgconfig lookup in {pkg_libdir_origin}')
460465
pkgconfig_paths = [pkg_libdir] if pkg_libdir else []
461466

@@ -465,6 +470,7 @@ def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any],
465470
if pkg_libdir and not self.is_found:
466471
mlog.debug(f'{pkg_name!r} could not be found in {pkg_libdir_origin}, '
467472
'this is likely due to a relocated python installation')
473+
return
468474

469475
# pkg-config files are usually accurate starting with python 3.8
470476
if not self.link_libpython and mesonlib.version_compare(self.version, '< 3.8'):

0 commit comments

Comments
 (0)