From 13a4879d837e407779128994235ce4749c822f50 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 29 Aug 2023 12:51:14 +0200 Subject: [PATCH] list python_requires in create graph.json (#14602) --- conan/api/model.py | 24 +++++++++---------- .../command_v2/test_combined_pkglist_flows.py | 12 ++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/conan/api/model.py b/conan/api/model.py index 8af51676eb0..72a45cb2d7d 100644 --- a/conan/api/model.py +++ b/conan/api/model.py @@ -83,19 +83,8 @@ def load_graph(graphfile, graph_recipes=None, graph_binaries=None): pkglist.lists["Local Cache"] = cache_list for node in graph["graph"]["nodes"].values(): - recipe = node["recipe"] - if recipe in (RECIPE_EDITABLE, RECIPE_CONSUMER, RECIPE_VIRTUAL, RECIPE_SYSTEM_TOOL): - continue - - ref = node["ref"] - ref = RecipeReference.loads(ref) - ref.timestamp = node["rrev_timestamp"] - recipe = recipe.lower() - if any(r == "*" or r == recipe for r in recipes): - cache_list.add_refs([ref]) - # We need to add the python_requires too - python_requires = node["python_requires"] + python_requires = node.get("python_requires") if python_requires is not None: for pyref, pyreq in python_requires.items(): pyrecipe = pyreq["recipe"] @@ -109,6 +98,17 @@ def load_graph(graphfile, graph_recipes=None, graph_binaries=None): remote_list = pkglist.lists.setdefault(pyremote, PackagesList()) remote_list.add_refs([pyref]) + recipe = node["recipe"] + if recipe in (RECIPE_EDITABLE, RECIPE_CONSUMER, RECIPE_VIRTUAL, RECIPE_SYSTEM_TOOL): + continue + + ref = node["ref"] + ref = RecipeReference.loads(ref) + ref.timestamp = node["rrev_timestamp"] + recipe = recipe.lower() + if any(r == "*" or r == recipe for r in recipes): + cache_list.add_refs([ref]) + remote = node["remote"] if remote: remote_list = pkglist.lists.setdefault(remote, PackagesList()) diff --git a/conans/test/integration/command_v2/test_combined_pkglist_flows.py b/conans/test/integration/command_v2/test_combined_pkglist_flows.py index 150dccc71a1..8bbfbeefe78 100644 --- a/conans/test/integration/command_v2/test_combined_pkglist_flows.py +++ b/conans/test/integration/command_v2/test_combined_pkglist_flows.py @@ -115,6 +115,18 @@ def test_graph_pkg_list_python_requires(self): assert len(pkglist) == 2 assert "96aec08148a2392127462c800e1c8af6" in pkglist["pytool/0.1"]["revisions"] + def test_graph_pkg_list_create_python_requires(self): + """ + include python_requires too + """ + c = TestClient(default_server_user=True) + c.save({"conanfile.py": GenConanfile("pytool", "0.1").with_package_type("python-require")}) + c.run("create . --format=json", redirect_stdout="graph.json") + c.run("list --graph=graph.json --format=json") + pkglist = json.loads(c.stdout)["Local Cache"] + assert len(pkglist) == 1 + assert "62a6a9e5347b789bfc6572948ea19f85" in pkglist["pytool/0.1"]["revisions"] + class TestGraphInfoToPkgList: def test_graph_pkg_list_only_built(self):