MCPcopy Create free account
hub / github.com/conda/constructor / get_condarc_content

Function get_condarc_content

constructor/utils.py:136–175  ·  view source on GitHub ↗

Get the condarc content string from the info dict. Returns the condarc content as a YAML string, or None if no condarc should be written. Handles both the new 'condarc' key (direct content) and the legacy 'write_condarc' approach (building from channel settings).

(info)

Source from the content-addressed store, hash-verified

134
135
136def get_condarc_content(info) -> str | None:
137 """
138 Get the condarc content string from the info dict.
139
140 Returns the condarc content as a YAML string, or None if no condarc should be written.
141 Handles both the new 'condarc' key (direct content) and the legacy 'write_condarc'
142 approach (building from channel settings).
143 """
144 from .conda_interface import MatchSpec # prevent circular import
145
146 condarc = info.get("condarc")
147 if condarc is None:
148 # The legacy approach
149 write_condarc = info.get("write_condarc")
150 default_channels = info.get("conda_default_channels")
151 channel_alias = info.get("conda_channel_alias")
152 channels = info.get("channels")
153 mirrored_channels = info.get("mirrored_channels")
154 if not (
155 write_condarc and (default_channels or channels or channel_alias or mirrored_channels)
156 ):
157 return None
158 condarc = {}
159 if default_channels:
160 condarc["default_channels"] = default_channels
161 if channels:
162 condarc["channels"] = channels
163 if channel_alias:
164 condarc["channel_alias"] = channel_alias
165 if mirrored_channels:
166 if "mamba" in {MatchSpec(spec).name for spec in info.get("specs", ())}:
167 condarc["mirrored_channels"] = mirrored_channels
168 else:
169 logger.warning(
170 "The 'mirrored_channels' key is only supported by mamba. "
171 "It will not be included in the installer."
172 )
173 if isinstance(condarc, dict):
174 condarc = yaml_to_string(condarc)
175 return condarc
176
177
178def ensure_transmuted_ext(info, url):

Calls 2

yaml_to_stringFunction · 0.85
getMethod · 0.80