diff options
| author | Eli Schwartz <eschwartz93@gmail.com> | 2025-11-10 11:23:05 -0500 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-11-14 03:16:18 -0500 |
| commit | c3d911e2f5d2118c92bc60ffcd3a5a8ff4f4a05e (patch) | |
| tree | 16165f521bee6052c4124bcab8927cb073b4cc07 /mesonbuild/interpreter | |
| parent | 2f1bc62dfff6c9b24ad524bca3637572ef304bf3 (diff) | |
| download | meson-c3d911e2f5d2118c92bc60ffcd3a5a8ff4f4a05e.tar.gz | |
make str and meson.version() API align again.
Regression in commit 6ee583e119b432fee03f908547729d5da030397e.
str.version_compare() accepts varargs unless the str was defined via
meson.version(), which isn't supposed to be a visible end user
distinction.
That being said, it makes no sense to support the special casing here.
- FeatureNew only compares conditions with min, not with max
- Having multiple min conditions is illogical and there's no need to
support it.
So we allow varargs for parity, but debug log that we can't handle it
specially and refrain from setting tmp_meson_version at all.
Fixes: https://github.com/mesonbuild/meson/issues/15217
Diffstat (limited to 'mesonbuild/interpreter')
| -rw-r--r-- | mesonbuild/interpreter/primitives/string.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/mesonbuild/interpreter/primitives/string.py b/mesonbuild/interpreter/primitives/string.py index 86616a39d..190e82a39 100644 --- a/mesonbuild/interpreter/primitives/string.py +++ b/mesonbuild/interpreter/primitives/string.py @@ -8,7 +8,7 @@ import os import typing as T from ... import mlog -from ...mesonlib import version_compare, version_compare_many, underscorify +from ...mesonlib import version_compare_many, underscorify from ...interpreterbase import ( InterpreterObject, MesonOperator, @@ -198,18 +198,26 @@ class MesonVersionString(str): class MesonVersionStringHolder(StringHolder): @noKwargs - @typed_pos_args('str.version_compare', str) @InterpreterObject.method('version_compare') - def version_compare_method(self, args: T.Tuple[str], kwargs: TYPE_kwargs) -> bool: + @typed_pos_args('str.version_compare', varargs=str, min_varargs=1) + def version_compare_method(self, args: T.Tuple[T.List[str]], kwargs: TYPE_kwargs) -> bool: unsupported = [] - if not args[0].strip().startswith('>'): - unsupported.append('non-upper-bounds (> or >=) constraints') + for constraint in args[0]: + if not constraint.strip().startswith('>'): + unsupported.append('non-upper-bounds (> or >=) constraints') + if len(args[0]) > 1: + FeatureNew.single_use('meson.version().version_compare() with multiple arguments', '1.10.0', + self.subproject, 'From 1.8.0 - 1.9.* it failed to match str.version_compare', + location=self.current_node) + unsupported.append('multiple arguments') + else: + self.interpreter.tmp_meson_version = args[0][0] if unsupported: mlog.debug('meson.version().version_compare() with', ' or '.join(unsupported), 'does not support overriding minimum meson_version checks.') - self.interpreter.tmp_meson_version = args[0] - return version_compare(self.held_object, args[0]) + return version_compare_many(self.held_object, args[0])[0] + # These special subclasses of string exist to cover the case where a dependency # exports a string variable interchangeable with a system dependency. This |
