-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[feature] Add hooks for validate method #17856
Changes from 11 commits
f0b295f
2b92afb
a7511f9
e3715f2
51bdc7d
58cae01
16fafd4
333e335
0615850
59c6a83
13e971b
a71eaaa
be0cb56
499afd9
57878a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,10 +29,11 @@ def __init__(self, conan_app, global_conf): | |
self._home_folder = conan_app.cache_folder | ||
self._global_conf = global_conf | ||
self._remote_manager = conan_app.remote_manager | ||
self._hook_manager = conan_app.conan_api.config.hook_manager | ||
# These are the nodes with pref (not including PREV) that have been evaluated | ||
self._evaluated = {} # {pref: [nodes]} | ||
compat_folder = HomePaths(conan_app.cache_folder).compatibility_plugin_path | ||
self._compatibility = BinaryCompatibility(compat_folder) | ||
self._compatibility = BinaryCompatibility(compat_folder, self._hook_manager) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want to execute the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still an open question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think so, I could remove it and add in the future, in case having a case. For now, we only have the CI case to be covered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then lets remove it. It is better to be minimalistic first, then add things when real use cases are requesting it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, removed on the commit 57878a1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd still like to see a more real use case for the feature, I haven't fully understood if it makes sense to be in the compatibility or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only real case listed right now is related to the CI: When the CI needs to skip a build, being checked in the pre_validate, but we do not want to change the recipe, by adding a new rule to raise ConanInvalidConfiguration. About the compatibility I do not see a real usage right now, because it's related to binary compatibility mechanism, sounds be something unrelated to the validate stage. |
||
unknown_mode = global_conf.get("core.package_id:default_unknown_mode", default="semver_mode") | ||
non_embed = global_conf.get("core.package_id:default_non_embed_mode", default="minor_mode") | ||
# recipe_revision_mode already takes into account the package_id | ||
|
@@ -397,7 +398,7 @@ def _config_version(self): | |
return RequirementsInfo(result) | ||
|
||
def _evaluate_package_id(self, node, config_version): | ||
compute_package_id(node, self._modes, config_version=config_version) | ||
compute_package_id(node, self._modes, config_version, self._hook_manager) | ||
|
||
# TODO: layout() execution don't need to be evaluated at GraphBuilder time. | ||
# it could even be delayed until installation time, but if we got enough info here for | ||
|
@@ -458,7 +459,7 @@ def _evaluate_single(n): | |
if node.path is not None: | ||
if node.path.endswith(".py"): | ||
# For .py we keep evaluating the package_id, validate(), etc | ||
compute_package_id(node, self._modes, config_version=config_version) | ||
compute_package_id(node, self._modes, config_version, self._hook_manager) | ||
# To support the ``[layout]`` in conanfile.txt | ||
if hasattr(node.conanfile, "layout"): | ||
with conanfile_exception_formatter(node.conanfile, "layout"): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
from conan.errors import ConanException | ||
|
||
valid_hook_methods = ["pre_export", "post_export", | ||
"pre_validate_build", "post_validate_build", | ||
"pre_validate", "post_validate", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can cover the real-world use cases with just 1 of these hooks, I'd go for that, do the minimal changes to satisfy the need. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So far, we have For other cases, @jcar87 can tell us more about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @memsharded I'll drop the hook for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, removed validate_build hook on the commit a71eaaa |
||
"pre_source", "post_source", | ||
"pre_generate", "post_generate", | ||
"pre_build", "post_build", "post_build_fail", | ||
|
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.
Talked with @AbrilRBS about this. It looks better than changing more methods because we need to forward the hook manager to
run_validate_package_id