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

Not skipping binaries of direct dependencies for packages being built #15128

Merged
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: 5 additions & 1 deletion conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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