summaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/detect.py
AgeCommit message (Collapse)Author
2025-12-17dependencies/detect: simplify logging tried methodsDylan Baker
Avoid extra method calls and repeating ourselves.
2025-12-17dependencies: Catch non MesonException in detect and give better messageDylan Baker
2025-12-17Dependencies: Make use of the DependencyCandidate classDylan Baker
This makes the type checking more reasonable (including fixing an issue that newer mypy is pointing out to us), consolidating special cases, and improving code readability.
2025-12-17dependencies: Require 'native' be passed in kwargsDylan Baker
This simplifies a bunch of cases, and likely fixes some annoying bugs in cross compile situations where should have been passing this and weren't.
2025-12-17dependencies: stop passing "language" as a keyword argumentDylan Baker
It's allowed in the `DependencyKeywordArguments` TypeDict already, so we now have two sources of truth. Additionally, it's often populated by reading from that dict, so we're just doing useless work.
2025-12-17dependencies: Annotate the DependencyPackages classDylan Baker
2025-10-20interpreter: remove dependency_kwargsDylan Baker
Since it's basically unusued, but the DEPENDENCY_KWS can be used instead This requires changing the number of arguments from 19 to 20 because the `DEPENDENCY_KWS` includes `disabler`, but the `permitted_dependency_kwargs` does not.
2025-10-20interpreter: port dependency version to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency required to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency native to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency method to typed_kwargsDylan Baker
This allows us a bunch of nice things: 1. We can use the DependencyMethods enum everywhere 2. The deprecated methods can be checked in the Interpreter, so we can now emit deprecation warnings for stuff that was deperecated in 0.44! 3. We can share this more strongly typed method everywhere
2025-10-20interpreter: port dependency language to typed_kwargsDylan Baker
2025-10-20dependency: Use a TypedDict to describe the keyword arguments to DependencyDylan Baker
This allows us to check that all of the keyword arguments are of the correct type.
2025-08-01dependencies: fill in defaults from DEPENDENCY_KWS when generating keyDylan Baker
Otherwise we run into issues where the key doesn't match when some values are empty and others are not. These values can be empty when they come from `find_external_dependency`, but will be initialized to a default when they come from the `Interpreter`.
2025-08-01dependencies: Allow None in dep_identifierDylan Baker
Because we're going to have None once we move to more typed_kwargs
2025-01-28dependencies/detect: make assertions more usefulDylan Baker
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-06-26dependencies: switch the delayed-import mechanism for custom dependenciesEli Schwartz
Simply store the module it is expected to be found in. That module then appends to the packages dict, which guarantees mypy can verify that it's got the right type -- there is no casting needed.
2023-06-26dependencies: defer importing a custom dependency until it is usedEli Schwartz
This lessens the amount of code imported at Meson startup by mapping each dependency to a dictionary entry and using a programmable import to dynamically return it. Minus 16 files and 6399 lines of code imported at startup.
2023-06-26dependencies: delay often-unused importsEli Schwartz
We expose detect.py as the mesonbuild.dependencies entrypoint and import it upfront everywhere. But unless the `dependency()` function is actually invoked, we don't need *any* of the private implementations for this. Avoid doing so until, as part of actual dependency lookup, we attempt that specific dependency method. This avoids importing big modules if `method:` is specified, and in most cases hopefully pkg-config works and we can avoid importing the cmake implementation particularly. Actually avoiding most of these imports requires more refactoring. But even so, the garden path no longer needs to import the dub dependency impl.
2023-06-26dependencies: Don't Repeat Yourself when it comes to lookup methodsEli Schwartz
We need to extend the candidates the same way per method, but we handle each method twice: once in explicit method checks, and once for auto. We can just handle auto as a special list of methods, though.
2023-06-01python: Use detect.find_external_dependency() for log consistencyXavier Claessens
py.find_installation().dependency() was not logging whether it is found or not. Use find_external_dependency() for consistency.
2023-02-01treewide: add future annotations importEli Schwartz
2022-11-30pylint: enable the set_membership pluginDylan Baker
Which adds the `use-set-for-membership` check. It's generally faster in python to use a set with the `in` keyword, because it's a hash check instead of a linear walk, this is especially true with strings, where it's actually O(n^2), one loop over the container, and an inner loop of the strings (as string comparison works by checking that `a[n] == b[n]`, in a loop). Also, I'm tired of complaining about this in reviews, let the tools do it for me :)
2022-09-12dependencies: log the real reason for a dependency lookup failingEli Schwartz
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.
2022-09-12dependencies: use better internal representation of factory methodsEli Schwartz
functools.partial preserves information about how the method was created, lambdas do not. Also, we just want to freeze the first argument and forward the rest anyway. This also lets us get rid of a mypy error that was being ignored.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge
2022-03-07treewide: string-quote the first argument to T.castEli Schwartz
Using future annotations, type annotations become strings at runtime and don't impact performance. This is not possible to do with T.cast though, because it is a function argument instead of an annotation. Quote the type argument everywhere in order to have the same effect as future annotations. This also allows linters to better detect in some cases that a given import is typing-only.
2022-03-07merge various TYPE_CHECKING blocks into oneEli Schwartz
A bunch of files have several T.TYPE_CHECKING blocks that each do some things which could just as well be done once, with a single `if` statement. Make them do so.
2021-12-17Fix mypy errorsDaniel Mensinger
2021-11-01various manual conversion of percent-formatted strings to f-stringsEli Schwartz
2021-10-26dep.name(): return dependency name even if dependency is not foundThomas Heijligen
The dep.name() function schould always return the name of the dependency as documented. No matter if it was found or not. https://mesonbuild.com/Reference-manual_returned_dep.html#depfound
2021-10-04coding style: don't format an empty string with another stringEli Schwartz
'{}'.format('foo') for any given value of 'foo' (in this case, a function returning a string), can always just be 'foo' directly, which is a lot more readable.
2021-09-14apply flake8 fixes for unused imports and missing importsEli Schwartz
2021-08-31pylint: turn on superflous-parensDylan Baker
We have a lot of these. Some of them are harmless, if unidiomatic, such as `if (condition)`, others are potentially dangerous `assert(...)`, as `assert(condtion)` works as expected, but `assert(condition, message)` will result in an assertion that never triggers, as what you're actually asserting is `bool(tuple[2])`, which will always be true.
2021-06-09typing: Rename some variablesDaniel Mensinger
2021-06-06typing: Fully annotate dependencies.{detect,factory} + some other fixesDaniel Mensinger
2021-06-04dependencies/detect: Add type annotations to find_external_dependencyDylan Baker
2021-06-03deps: Split dependencies.baseDaniel Mensinger
Split the Factory and dependency classes out of the base.py script to improve maintainability.