-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interpreter: deprecate using an array for project(license:) #9940
base: master
Are you sure you want to change the base?
interpreter: deprecate using an array for project(license:) #9940
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9940 +/- ##
==========================================
- Coverage 68.71% 67.23% -1.49%
==========================================
Files 406 203 -203
Lines 87766 43892 -43874
Branches 19518 9762 -9756
==========================================
- Hits 60311 29512 -30799
+ Misses 22892 12130 -10762
+ Partials 4563 2250 -2313
Continue to review full report at Codecov.
|
LGTM |
aa5c023
to
7007891
Compare
@@ -1135,6 +1135,9 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str | |||
if self.build.project_version is None: | |||
self.build.project_version = self.project_version | |||
proj_license = kwargs['license'] | |||
if len(proj_license) > 1: | |||
FeatureDeprecated.single_use('license as an array of strings', '0.62.0', self.subproject, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we actually need a version-gated feature? We recommend against it purely because it is "a bad idea" and the alternative is to do something that has also worked since this kwarg was added. So there's no reason to only recommend against it once you bump your minimum meson.build high enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the way this is written is bad. I've changed it so that the function takes a str | list[str]
, and that passing list[str]
is deprecated, and the warning is gated on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this does fine tune the check to also trigger on license: ['GPL-2.0-only']
it doesn't really answer my question, which is whether we should use mlog.deprecation
and print warnings even for projects that support Meson 0.45, instead of using FeatureDeprecated and only warning people away from this once they bump meson_version: '>=0.62'
.
Again, the point of a FeatureDeprecated is typically because we change how things work and add new features which replace old and badly designed features, so as a result a FeatureDeprecated does not warn you if you cannot migrate to the new method due to your requirement to support old versions of Meson.
We also don't warn you at all if you don't specify any minimum version. Whereas a direct mlog.deprecation would be printed rather than ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a change to add a warning in the even that you're using a version < 0.62 in addition to the deprecation warning (either the FeatureDeprecated or the separate warning). The FeatureDeprecated is still useful as passing an array should go away, but you're right, encouraging the use of an SPDX license expression even in older versions is desirable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a very complicated way to add two distinct warnings for one thing, when passing as an array is still not something that needs to version-gated the warning.
Deprecating a feature with a replacement that has been available for as long as the feature itself, doesn't need a version gate, whether that feature is "multiple license strings or "passing as an array".
We can just tell people using Meson 0.45 "you know, it's kind of bad to not use SPDX, and since you're going to use SPDX, it's kind of silly to pass a single string wrapped in an array, and also this still works on 0.45 anyway (and quite frankly it works on like 0.25 also)".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm strongly against removing the FeatureDeprecated
, because it provides a clean way for projects receiving bug reports about the deprecation to know exactly what's happening, and when it was deprecated. Having been on the end of CMake policy bug reports/PRs that don't include that information, I think this makes for good user experience. It's immaterial that the replacement has been available since the beginning, 0.62 is when we declared "this is going away".
The other problem we have, is that we don't (and can't easily without external deps) verify that the project license is an SPDX expression, only that it's an array or a single string. That string could easily be LOLZ!1!
, and we can't say with certainty "this is not SPDX!". But we can say that ['GPL', 'MIT']
is ambiguous, knock that off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would imply we should extend FeatureCheck with a .single_use(..., always_warn=True)
option, and just emit the FeatureDeprecated but ensure it is always logged as a full warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcbaker could you update your PR to add FeatureDeprecated.single_use(..., always_warn=True) please?
7007891
to
ab6b5ef
Compare
80a21c1
to
9dac45f
Compare
9dac45f
to
84630b6
Compare
This is useful for cases where the replacement has been present for as long (or longer) than the deprecated functionality, but we would still like to signal to users when the given functionality was deprecated.
It's ambiguous as to whether the array means AND or OR, and ambiguity in software licenses is *not* a good thing. Further, SPDX (which we generally recommend) is an ISO standard and well understood outside of Meson (including in SBOM software). Deprecate passing and array and suggest using an SDPX expression instead. If an older version is targeted, then a warning is generated if using an array with a length > 1 to use an SPDX expression instead.
We do check the location as part of the "emit a warning only once" mechanism already, since at least: d39b330
84630b6
to
af2ae8e
Compare
@xclaesse, @eli-schwartz: I've rebased this, added the requested |
'but uses feature deprecated since', | ||
f"'{self.feature_version}':", | ||
f'{self.feature_name}.', | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we need 2 different messages here, what's wrong with the original one? Also it probably should be fatal when targeting Meson >=0.63 but since that's inside project()
I don't think the target meson version is set already, is it?
Sorry for nitpicking, maybe I'm just overthinking this simple PR tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the normal message makes sense in this case, since you'd get a warning like: Project is targing >= 0.52 but using a feature deprecated since 0.63.
That seems confusing to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the dedicated warning message makes sense.
However I also agree with @xclaesse that it seems weird to mark it as non-fatal, because if we always warn about it and can always use the better non-deprecated version of it, then we also do want it to trigger --fatal-meson-warnings.
@@ -631,8 +631,6 @@ def use(self, subproject: 'SubProject', location: T.Optional['mparser.BaseNode'] | |||
feature_key = (self.feature_name, location) | |||
if feature_key in register[self.feature_version]: | |||
# Don't warn about the same feature multiple times | |||
# FIXME: This is needed to prevent duplicate warnings, but also | |||
# means we won't warn about a feature used in multiple places. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, but the actual fix was in 7a033c7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. the discussion at #9488 (comment)
@@ -702,7 +719,7 @@ def log_usage_warning(self, tv: str, location: T.Optional['mparser.BaseNode']) - | |||
] | |||
if self.extra_message: | |||
args.append(self.extra_message) | |||
mlog.warning(*args, location=location) | |||
mlog.warning(*args, location=location, fatal=not always) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be dropped. The default is True, but we're setting it to False iff it is an always_warn
.
This means that a deprecation for something that is always deprecated and always wrong and always should be replaced... does NOT trigger --fatal-meson-warnings, even though it really should.
It's ambiguous as to whether the array means AND or OR, and ambiguity in
software licenses is not a good thing. Further, SPDX (which we
generally recommend) is an ISO standard and well understood outside of
Meson (including in SBOM software). Deprecate passing and array and
suggest using an SDPX expression instead.