Skip to content

Commit

Permalink
fix build_id() removal of require (#12019)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Sep 5, 2022
1 parent 1757fc4 commit 1f81c65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 6 additions & 3 deletions conans/model/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def __bool__(self):
return bool(self._data)

def get(self, ref, build=None, **kwargs):
return self._get(ref, build, **kwargs)[1]

def _get(self, ref, build=None, **kwargs):
if build is None:
current_filters = self._require_filter or {}
if "build" not in current_filters:
Expand Down Expand Up @@ -54,14 +57,14 @@ def get(self, ref, build=None, **kwargs):
if not ret:
raise KeyError("'{}' not found in the dependency set".format(ref))

_, value = ret[0]
return value
key, value = ret[0]
return key, value

def __getitem__(self, name):
return self.get(name)

def __delitem__(self, name):
r = self.get(name)
r, _ = self._get(name)
del self._data[r]

def items(self):
Expand Down
18 changes: 18 additions & 0 deletions conans/test/integration/package_id/build_id_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.test.assets.genconanfile import GenConanfile
from conans.test.utils.tools import TestClient
from conans.util.files import load

Expand Down Expand Up @@ -275,3 +276,20 @@ def build(self):
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5", client.out)
client.run("create . --name=pkg --version=0.1 --user=user --channel=channel", assert_error=True)
self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5", client.out)


def test_remove_require():
c = TestClient()
remove = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
name = "consumer"
version = "1.0"
requires = "dep/1.0"
def build_id(self):
self.info_build.requires.remove("dep")
""")
c.save({"dep/conanfile.py": GenConanfile("dep", "1.0"),
"consumer/conanfile.py": remove})
c.run("create dep")
c.run("create consumer")

0 comments on commit 1f81c65

Please sign in to comment.