Skip to content
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

fix profile [tool_requires] using revisions #14337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions conans/client/graph/graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,12 @@ def _prepare_node(node, profile_host, profile_build, down_options):

# Apply build_tools_requires from profile, overriding the declared ones
profile = profile_host if node.context == CONTEXT_HOST else profile_build
tool_requires = profile.tool_requires
for pattern, tool_requires in tool_requires.items():
for pattern, tool_requires in profile.tool_requires.items():
if ref_matches(ref, pattern, is_consumer=conanfile._conan_is_consumer):
for tool_require in tool_requires: # Do the override
if str(tool_require) == str(ref): # FIXME: Ugly str comparison
continue # avoid self-loop of build-requires in build context
# FIXME: converting back to string?
node.conanfile.requires.tool_require(str(tool_require),
node.conanfile.requires.tool_require(tool_require.repr_notime(),
raise_if_duplicated=False)

def _initialize_requires(self, node, graph, graph_lock):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,28 @@ def test_consumer_patterns_loop_error():
client.run("install consumer --build=missing -pr:b=profile.txt -pr:h=profile.txt")
assert "tool1/1.0: Created package" in client.out
assert "tool2/1.0: Created package" in client.out


def test_tool_requires_revision_profile():
# We shoul be able to explicitly [tool_require] a recipe revision in the profile
c = TestClient()
build_profile = textwrap.dedent("""\
[tool_requires]
*:tool/0.1#2d65f1b4af1ce59028f96adbfe7ed5a2
""")
c.save({"tool/conanfile.py": GenConanfile("tool", "0.1"),
"cmake/conanfile.py": GenConanfile("cmake", "0.1"),
"app/conanfile.py": GenConanfile("app", "0.1").with_tool_requires("cmake/0.1"),
"build_profile": build_profile})
c.run("export tool")
rev1 = c.exported_recipe_revision()
assert rev1 == "2d65f1b4af1ce59028f96adbfe7ed5a2"
# Create a new tool revision to proof that we can still require the old one
c.save({"tool/conanfile.py": GenConanfile("tool", "0.1").with_class_attribute("myvar=42")})
c.run("export tool")
rev2 = c.exported_recipe_revision()
assert rev2 != rev1
c.run("export cmake")
c.run("graph info app -pr:b=build_profile --build=*")
assert f"tool/0.1#{rev1}" in c.out
assert rev2 not in c.out