Skip to content

Commit

Permalink
Not skipping binaries of direct dependencies for packages being built (
Browse files Browse the repository at this point in the history
…#15128)

* to explorer teh concept of not skipping directs

* fix

* wip

* review
  • Loading branch information
memsharded authored Feb 5, 2024
1 parent d4e7b3e commit 1268572
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
6 changes: 5 additions & 1 deletion conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,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
Expand Down
40 changes: 40 additions & 0 deletions conans/test/integration/command/install/install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1268572

Please sign in to comment.