Skip to content

Commit

Permalink
list python_requires in create graph.json (#14602)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Aug 29, 2023
1 parent c888659 commit 13a4879
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
24 changes: 12 additions & 12 deletions conan/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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())
Expand Down
12 changes: 12 additions & 0 deletions conans/test/integration/command_v2/test_combined_pkglist_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 13a4879

Please sign in to comment.