From a54212543d53c12e2231f8e66149017755805889 Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 31 May 2019 10:16:32 +0200 Subject: [PATCH] fix version range python_require update --- conans/client/graph/python_requires.py | 2 +- .../python_requires/python_requires_test.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/conans/client/graph/python_requires.py b/conans/client/graph/python_requires.py index 0d23f1c905c..2c20e6ec7cd 100644 --- a/conans/client/graph/python_requires.py +++ b/conans/client/graph/python_requires.py @@ -45,7 +45,7 @@ def _look_for_require(self, require): except KeyError: ref = ConanFileReference.loads(require) requirement = Requirement(ref) - self._range_resolver.resolve(requirement, "python_require", update=False, + self._range_resolver.resolve(requirement, "python_require", update=self._update, remotes=self._remotes) ref = requirement.ref result = self._proxy.get_recipe(ref, self._check_updates, self._update, diff --git a/conans/test/functional/python_requires/python_requires_test.py b/conans/test/functional/python_requires/python_requires_test.py index c24409699e4..9cd23d7f1b4 100644 --- a/conans/test/functional/python_requires/python_requires_test.py +++ b/conans/test/functional/python_requires/python_requires_test.py @@ -482,6 +482,40 @@ def configure(self): client2.run("install . --update") self.assertIn("conanfile.py: PYTHON REQUIRE VAR 143", client2.out) + def update_ranges_test(self): + # https://github.com/conan-io/conan/issues/4650#issuecomment-497464305 + client = TestClient(servers={"default": TestServer()}, + users={"default": [("lasote", "mypass")]}) + conanfile = """from conans import ConanFile +somevar = 42 +class MyConanfileBase(ConanFile): + pass +""" + client.save({"conanfile.py": conanfile}) + client.run("export . MyConanfileBase/1.1@lasote/testing") + client.run("upload * --confirm") + + client2 = TestClient(servers=client.servers, users={"default": [("lasote", "mypass")]}) + + reuse = """from conans import python_requires +base = python_requires("MyConanfileBase/[>1.0]@lasote/testing") +class PkgTest(base.MyConanfileBase): + def configure(self): + self.output.info("PYTHON REQUIRE VAR %s" % base.somevar) +""" + + client2.save({"conanfile.py": reuse}) + client2.run("install .") + self.assertIn("conanfile.py: PYTHON REQUIRE VAR 42", client2.out) + + client.save({"conanfile.py": conanfile.replace("42", "143")}) + # Make sure to bump the version! + client.run("export . MyConanfileBase/1.2@lasote/testing") + client.run("upload * --confirm") + + client2.run("install . --update") + self.assertIn("conanfile.py: PYTHON REQUIRE VAR 143", client2.out) + def duplicate_pyreq_test(self): t = TestClient() conanfile = textwrap.dedent("""