-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MetaData.get_section
handling for "source" & "outputs"
#5112
Conversation
conda_build/metadata.py
Outdated
assert ( | ||
not index | ||
), f"Got non-zero index ({index}), but section {section} is not a list." | ||
if isinstance(section_data, dict) and index: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(section_data, dict) and index: | |
if isinstance(section_data, Mapping) and index: |
you might need to import it as well
from collections.abc import Mapping
conda_build/metadata.py
Outdated
if len(names) == 2: | ||
section, key = names | ||
index = None | ||
elif len(names) == 3: | ||
section, index, key = names | ||
assert section == "source", "Section is not a list: " + section | ||
if section not in OPTIONALLY_ITERABLE_FIELDS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunate name, given how dicts are also iterable, technically speaking. Not that we should change it, but I wonder if MAYBE_LIST_OF_DICTS_FIELDS
(or similar) would have been better.
m.path = "" | ||
m._meta_path = "" | ||
m.requirements_path = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialization missing that was discovered by the newly added unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh!
Co-authored-by: jaimergp <[email protected]>
m.path = "" | ||
m._meta_path = "" | ||
m.requirements_path = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh!
@@ -622,6 +622,7 @@ def parse(data, config, path=None): | |||
"prelink_message": None, | |||
"readme": None, | |||
}, | |||
"extra": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra
could be anything else (scalar or sequence, not just mapping) acc. to https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#extra-section .
This broke an assumption in conda-smithy
at least: conda-forge/conda-smithy#1816 .
So, technically a breaking change; but I'd be okay with requiring a mapping here.
This needs an update to the docs, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened gh-5125 to track this.
Description
The recipe format supports 9 fields, all of which are expected to be
dict
except "source" and "outputs" which can be either a singledict
or alist
ofdict
.Previously this distinction had to be uniquely handled throughout out the code, e.g.:
conda-build/conda_build/build.py
Lines 1567 to 1569 in 061063f
It instead makes more sense for the
MetaData.get_section
to auto handle this sanitization for us and to always return alist
ofdict
for "source" and "outputs".Resolves #5111
Checklist - did you ...
news
directory (using the template) for the next release's release notes?Add / update outdated documentation?