-
Notifications
You must be signed in to change notification settings - Fork 988
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
Warn when using patching function and no_copy_source is True #17162
Warn when using patching function and no_copy_source is True #17162
Conversation
@@ -18,7 +18,7 @@ def conanfile(): | |||
with_require("base/1.0")) | |||
|
|||
conan_file += """ | |||
no_copy_sources = True | |||
no_copy_source = True |
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 was a typo in the test conanfile, but the behaviour is identical in these tests
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.
The thing is that as long as these functions are called inside the source method (For the patch case 100%, replace_in_file() also has valid use-cases inside the package method, but it's a diferent deal!), this would not be a problem
The issue arises when recipes call these methods in the build() method - CCI is almost exclusively like this, with few recipes doing it in the source() method, probably as a byproduct of old Conan 1 behaviour
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 am not sure if I understand.
Patches and replace_in_file should be applied in general in the source()
method, over the source folder. So they shouldn't warn by default.
The fact that ConanCenter patches unnecessarily in the build()
method is what should be updated, most of them should patch in the source()
method, as the patches are not configuration-specific.
We're going with the linter approach to be released soon, as this would create many false positives for users that are following the guidelines properly, and the added complexity of inspecting the stack to check for the build method is not worth it in our opinion |
Yes - this has always been a problem. I suppose patching in |
Conan 1 documentation always advocated for doing this in the source() method as well - and the source folder is deemed immutable once the the source() method has finished, but that the contents of the source folder should be platform (including settings and options) agnostic. Conan 2 does have that temporary copy of the source folder during build - so platform dependent changes are "safe" in the build() method. I think it's a mix of that, alongside a mentality of "the source() method should be the upstream sources, untouched" - but I think the conandata.yml already has a clear source of truth for that anyway. And for traceability purposes, having the |
Changelog: Feature: Warn when patching files and the recipe has
no_copy_source = True
, which could lead to unforseen issuesDocs: Omit
Some questions remain as to:
self.source_folder
?