@@ -113,8 +113,9 @@ def _get_requested_by(nodes, node_id, artifact_type):
113113
114114class _BuildInfo :
115115
116- def __init__ (self , graph , name , number , repositories , build_url = None , with_dependencies = False ,
116+ def __init__ (self , conan_api , graph , name , number , repositories , build_url = None , with_dependencies = False ,
117117 add_cached_deps = False , url = None , user = None , password = None ):
118+ self ._conan_api = conan_api
118119 self ._graph = graph
119120 self ._name = name
120121 self ._number = number
@@ -165,6 +166,12 @@ def _get_origin_repo(self, node):
165166 f"The package was not found in any of the specified repositories: { ', ' .join (self ._repositories )} "
166167 )
167168
169+ def get_artifacts_folder (self , node , artifact_type ):
170+ if artifact_type == "package" :
171+ return node .get ("package_folder" )
172+ else :
173+ reference = RecipeReference .loads (node .get ("ref" ))
174+ return self ._conan_api .cache .export_path (reference )
168175
169176 def get_artifacts (self , node , artifact_type , is_dependency = False ):
170177 """
@@ -186,14 +193,14 @@ def get_artifacts(self, node, artifact_type, is_dependency=False):
186193 def _get_local_artifacts ():
187194 local_artifacts = []
188195 missing_artifacts = []
189- artifacts_folder = node . get ( "package_folder" ) if artifact_type == "package" else node . get ( "recipe_folder" )
196+ artifacts_folder = self . get_artifacts_folder ( node , artifact_type )
190197 if artifacts_folder is None and artifact_type == "package" and node .get ("binary" ) == "Skip" :
191198 ConanOutput ().warning (f"Package is marked as 'Skip' for { node .get ('ref' )} and will not be included "
192199 "into the Build Info. If you want to get it included, use the conf argument: "
193200 "'-c:a tools.graph:skip_binaries=False' in your conan create/install command." )
194201 return (local_artifacts , missing_artifacts )
195202
196- artifacts_folder = Path (node . get ( "package_folder" )) if artifact_type == "package" else Path ( node . get ( "recipe_folder" ) )
203+ artifacts_folder = Path (artifacts_folder )
197204 dl_folder = artifacts_folder .parents [0 ] / "d"
198205 dl_folder_files = [file for file in dl_folder .glob ("*" ) if file .name in artifacts_names ]
199206 artifacts_folder_files = [file for file in artifacts_folder .glob ("*" ) if file .name in artifacts_names ]
@@ -279,7 +286,7 @@ def _get_remote_artifacts(artifact):
279286 if sources_artifact :
280287 artifacts .append (sources_artifact )
281288
282- folder = node . get ( "package_folder" ) if artifact_type == "package" else node . get ( "recipe_folder" )
289+ folder = self . get_artifacts_folder ( node , artifact_type )
283290 if not artifacts and folder :
284291 raise ConanException (f"There are missing artifacts for the { node .get ('ref' )} { artifact_type } . "
285292 "Check that you have all the packages installed in the Conan cache when creating the Build Info." )
@@ -437,8 +444,7 @@ def build_info_create(conan_api: ConanAPI, parser, subparser, *args):
437444 data ["graph" ]["nodes" ].pop ("0" )
438445
439446
440- bi = _BuildInfo (data , args .build_name , args .build_number ,
441- repositories = args .repository ,
447+ bi = _BuildInfo (conan_api , data , args .build_name , args .build_number , repositories = args .repository ,
442448 build_url = args .build_url ,
443449 with_dependencies = args .with_dependencies ,
444450 add_cached_deps = args .add_cached_deps , url = url , user = user , password = password )
@@ -629,7 +635,7 @@ def build_info_append(conan_api: ConanAPI, parser, subparser, *args):
629635 if not any (d ['id' ] == module .get ('id' ) for d in all_modules ):
630636 all_modules .append (module )
631637
632- bi = _BuildInfo (None , args .build_name , args .build_number , None )
638+ bi = _BuildInfo (conan_api , None , args .build_name , args .build_number , None )
633639 bi_json = bi .header ()
634640 bi_json .update ({"modules" : all_modules })
635641 return json .dumps (bi_json , indent = 4 )
0 commit comments