Skip to content

Commit

Permalink
python.dependency(): Do not stop when first candidate is not found
Browse files Browse the repository at this point in the history
It has to lookup the dependency with required=False otherwise it raises
an exception when the first candidate (pkg-config) failed.
  • Loading branch information
xclaesse authored and nirbheek committed Nov 2, 2021
1 parent 55c87f5 commit 77f8f5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mesonbuild/modules/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,12 @@ def dependency_method(self, args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') ->
if disabled:
mlog.log('Dependency', mlog.bold('python'), 'skipped: feature', mlog.bold(feature), 'disabled')
else:
new_kwargs = kwargs.copy()
new_kwargs['required'] = False
methods = process_method_kw({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM}, kwargs)
for d in python_factory(self.interpreter.environment,
MachineChoice.BUILD if kwargs.get('native', False) else MachineChoice.HOST,
kwargs,
process_method_kw({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM}, kwargs),
self):
new_kwargs, methods, self):
dep = d()
if dep.found():
break
Expand Down
4 changes: 4 additions & 0 deletions test cases/unit/101 python without pkgconfig/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project('python wihtout pkgconfig', 'c')

# This unit test is ran with PKG_CONFIG=notfound
import('python').find_installation().dependency()
4 changes: 4 additions & 0 deletions unittests/platformagnostictests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ def write_file(code: str):
# platlib is allowed, only python.platlib is reserved.
fname = write_file("option('platlib', type: 'string')")
interp.process(fname)

def test_python_dependency_without_pkgconfig(self):
testdir = os.path.join(self.unit_test_dir, '101 python without pkgconfig')
self.init(testdir, override_envvars={'PKG_CONFIG': 'notfound'})

0 comments on commit 77f8f5f

Please sign in to comment.