-
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 8 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
from conan.api.model import PkgReference | ||
from conan.api.model import RecipeReference | ||
from conans.util.files import load | ||
from conans.client.hook_manager import HookManager | ||
|
||
|
||
class GraphBinariesAnalyzer: | ||
|
@@ -31,15 +32,16 @@ def __init__(self, conan_app, global_conf): | |
self._remote_manager = conan_app.remote_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(conan_app.cache_folder) | ||
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 | ||
embed_mode = global_conf.get("core.package_id:default_embed_mode", default="full_mode") | ||
python_mode = global_conf.get("core.package_id:default_python_mode", default="minor_mode") | ||
build_mode = global_conf.get("core.package_id:default_build_mode", default=None) | ||
self._modes = unknown_mode, non_embed, embed_mode, python_mode, build_mode | ||
self._hook_manager = HookManager(HomePaths(self._home_folder).hooks_path) | ||
AbrilRBS marked this conversation as resolved.
Show resolved
Hide resolved
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 not instantiate here a new HookManager 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. Ditto. |
||
|
||
|
||
@staticmethod | ||
def _evaluate_build(node, build_mode): | ||
|
@@ -397,7 +399,8 @@ 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=config_version, | ||
hook_manager=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 +461,8 @@ 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=config_version, | ||
hook_manager=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.
You shouldn't instantiate
HookManager
here anymore.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.
Done, consuming hook_manager from conan_api.config.hook_manager instead. Please, see the commit 59c6a83