diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-08-29 19:31:38 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-12 19:16:59 -0400 |
commit | 719dd0d2a04592812194e8588279827ec52fc92e (patch) | |
tree | 2377d9867c777d0262a34c249c0cc3c7f0c30b3d /mesonbuild/dependencies | |
parent | b821a0351136b3b3872e2ba9da8f7c67c4275449 (diff) | |
download | meson-719dd0d2a04592812194e8588279827ec52fc92e.zip meson-719dd0d2a04592812194e8588279827ec52fc92e.tar.gz meson-719dd0d2a04592812194e8588279827ec52fc92e.tar.bz2 |
dependencies: log the real reason for a dependency lookup failing
In the debug logs, always log if a dependency lookup raises a
DependencyException. In the `required: false` case, this information
would otherwise disappear forever, and we would just not even log that
we tried it -- it doesn't appear in "(tried x, y and z)".
In the `required: true` case, we would re-raise the first exception if
it failed to be detected. Update the raise message with the same
information we print to the debug logs, indicating which dependency and
which method was used in the failing attempt.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 4 | ||||
-rw-r--r-- | mesonbuild/dependencies/detect.py | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index afe70c7..d901ef9 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -406,7 +406,7 @@ class ExternalDependency(Dependency, HasNativeKwarg): mlog.log(*found_msg) if self.required: - m = f'Unknown version of dependency {self.name!r}, but need {self.version_reqs!r}.' + m = f'Unknown version, but need {self.version_reqs!r}.' raise DependencyException(m) else: @@ -423,7 +423,7 @@ class ExternalDependency(Dependency, HasNativeKwarg): mlog.log(*found_msg) if self.required: - m = 'Invalid version of dependency, need {!r} {!r} found {!r}.' + m = 'Invalid version, need {!r} {!r} found {!r}.' raise DependencyException(m.format(self.name, not_found, self.version)) return diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py index 6e7d6d9..ebbcc2f 100644 --- a/mesonbuild/dependencies/detect.py +++ b/mesonbuild/dependencies/detect.py @@ -113,8 +113,11 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str, d._check_version() pkgdep.append(d) except DependencyException as e: + assert isinstance(c, functools.partial), 'for mypy' + bettermsg = f'Dependency lookup for {name} with method {c.func.log_tried()!r} failed: {e}' + mlog.debug(bettermsg) + e.args = (bettermsg,) pkg_exc.append(e) - mlog.debug(str(e)) else: pkg_exc.append(None) details = d.log_details() |