Skip to content

Commit c958e99

Browse files
authored
Add support for recipe.yaml metadata (#25)
1 parent 6d0248c commit c958e99

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

conda_metadata_app/pages/main_page.py

+30-6
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,19 @@ def provenance_urls(package_name: str, channel: str, data: dict | None = None) -
303303
if not package_name or not data:
304304
return [""]
305305
if data is not None:
306-
remote_url = data.get("rendered_recipe", {}).get("extra", {}).get("remote_url")
307-
if remote_url:
306+
if extra := data.get("rendered_recipe", {}).get("extra", {}): # meta.yaml
307+
pass
308+
elif extra := data.get("about", {}).get("extra", {}): # recipe.yaml
309+
pass
310+
else:
311+
logger.warning("Did not find extra metadata section")
312+
remote_url = extra.get("remote_url")
313+
if remote_url := extra.get("remote_url"):
308314
if remote_url.startswith("[email protected]:"):
309315
remote_url = remote_url.replace("[email protected]:", "https://github.com/")
310316
if remote_url.endswith(".git"):
311317
remote_url = remote_url[:-4]
312-
sha = data.get("rendered_recipe", {}).get("extra", {}).get("sha")
318+
sha = extra.get("sha")
313319
if sha and remote_url.startswith("https://github.com/"):
314320
return [f"{remote_url}/commit/{sha}"]
315321
return remote_url
@@ -1125,9 +1131,26 @@ def disable_button(query):
11251131
)
11261132
download = f"[artifact download]({_download_url})"
11271133
maintainers = []
1128-
for user in (
1129-
data.get("rendered_recipe", {}).get("extra", {}).get("recipe-maintainers", ["*N/A*"])
1130-
):
1134+
if recipe := data.get("rendered_recipe", {}).get("recipe"): # recipe.yaml
1135+
recipe_format = f"recipe.yaml v{recipe.get("schema_version", 1)}"
1136+
rattler_build_version = (
1137+
data.get("rendered_recipe").get("system_tools").get("rattler-build", "")
1138+
)
1139+
built_with = f"`rattler-build {rattler_build_version}`"
1140+
else:
1141+
rendered_recipe = data["rendered_recipe"]
1142+
recipe_format = "meta.yaml"
1143+
conda_build_version = data.get("about", {}).get("conda_build_version", "")
1144+
conda_version = data.get("about", {}).get("conda_version", "")
1145+
built_with = "N/A"
1146+
if conda_build_version:
1147+
built_with = f"`conda-build {conda_build_version}`"
1148+
if conda_version:
1149+
built_with += f", `conda {conda_version}`"
1150+
extra = data.get("rendered_recipe", {}).get("extra", {}) or data.get(
1151+
"rendered_recipe", {}
1152+
).get("recipe", {}).get("extra", {})
1153+
for user in extra.get("recipe-maintainers", ["*N/A*"]):
11311154
if user == "*N/A*":
11321155
maintainers.append(user)
11331156
elif "/" in user: # this is a team
@@ -1156,6 +1179,7 @@ def disable_button(query):
11561179
| `{channel}` | `{subdir}` | `{bar_esc(build_str)}` | `{extension}` |
11571180
| **License** | **Uploaded** | **Maintainers** | **Provenance** |
11581181
| `{bar_esc(about.get("license", "*N/A*"))}` | {uploaded} | {maintainers} | {provenance} |
1182+
| **Recipe:** | `{recipe_format}` | **Built with**: | {built_with} |
11591183
| **Links:** | {download} | {project_urls} | {dashboard_markdown_links} |
11601184
"""
11611185
)

0 commit comments

Comments
 (0)