diff --git a/conans/client/graph/graph_binaries.py b/conans/client/graph/graph_binaries.py index 658687c3d5d..f516da36c52 100644 --- a/conans/client/graph/graph_binaries.py +++ b/conans/client/graph/graph_binaries.py @@ -383,7 +383,11 @@ def _skip_binaries(graph): new_root_nodes = set() for node in root_nodes: # The nodes that are directly required by this one to build correctly - deps_required = set(d.node for d in node.transitive_deps.values() if d.require.files) + is_consumer = not (node.recipe != RECIPE_CONSUMER and + node.binary not in (BINARY_BUILD, BINARY_EDITABLE_BUILD, + BINARY_EDITABLE)) + deps_required = set(d.node for d in node.transitive_deps.values() if d.require.files + or (d.require.direct and is_consumer)) # second pass, transitive affected. Packages that have some dependency that is required # cannot be skipped either. In theory the binary could be skipped, but build system diff --git a/conans/test/integration/command/install/install_test.py b/conans/test/integration/command/install/install_test.py index 813c7caeee0..0a0b369fb6c 100644 --- a/conans/test/integration/command/install/install_test.py +++ b/conans/test/integration/command/install/install_test.py @@ -554,3 +554,43 @@ def package_info(self): data = json.loads(client.stdout) conf_info = data["graph"]["nodes"]["1"]["conf_info"] assert {'user.myteam:myconf': 'myvalue'} == conf_info + + +def test_install_json_format_not_visible(): + """ + The dependencies that are needed at built time, even if they are not visible, or not standard + libraries (headers=False, libs=False, run=False), like for example some build assets + So direct dependencies of a consumer package or a package that needs to be built cannot be + skipped + """ + c = TestClient() + dep = GenConanfile("dep", "0.1").with_package_file("somefile.txt", "contents!!!") + app = textwrap.dedent(""" + import os + from conan import ConanFile + from conan.tools.files import load + + class Pkg(ConanFile): + settings = "os", "arch", "build_type" + name="pkg" + version="0.0.1" + + def requirements(self): + self.requires("dep/0.1", visible=False, headers=False, libs=False, run=False) + + def build(self): + p = os.path.join(self.dependencies["dep"].package_folder, "somefile.txt") + c = load(self, p) + self.output.info(f"LOADED! {c}") + """) + c.save({"dep/conanfile.py": dep, + "app/conanfile.py": app}) + c.run("export-pkg dep") + c.run("install app --format=json") + c.assert_listed_binary({"dep/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Cache")}) + data = json.loads(c.stdout) + pkg_folder = data["graph"]["nodes"]["1"]["package_folder"] + assert pkg_folder is not None + + c.run("create app") + assert "pkg/0.0.1: LOADED! contents!!!" in c.out