Skip to content

Commit

Permalink
Merge pull request #423 from maresb/handle-nodefaults
Browse files Browse the repository at this point in the history
Handle nodefaults in all specs
  • Loading branch information
maresb authored Jun 11, 2023
2 parents d25cc37 + cf0d667 commit 60991f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion conda_lock/models/lock_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ def content_hash_for_platform(self, platform: str) -> str:
def validate_channels(cls, v: List[Union[Channel, str]]) -> List[Channel]:
for i, e in enumerate(v):
if isinstance(e, str):
v[i] = Channel.from_string(e)
e = Channel.from_string(e)
v[i] = e
if e.url == "nodefaults":
raise ValueError("nodefaults channel is not allowed, ref #418")
return typing.cast(List[Channel], v)
5 changes: 5 additions & 0 deletions conda_lock/src_parser/meta_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def parse_meta_yaml_file(
meta_yaml_data = yaml.safe_load(rendered)

channels = get_in(["extra", "channels"], meta_yaml_data, [])
try:
# conda-lock will use `--override-channels` so nodefaults is redundant.
channels.remove("nodefaults")
except ValueError:
pass

# parse with selectors for each target platform
dep_map = {
Expand Down
9 changes: 8 additions & 1 deletion conda_lock/src_parser/pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,16 @@ def specification_with_dependencies(
if dep.name in force_pypi:
dep.manager = "pip"

channels = get_in(["tool", "conda-lock", "channels"], toml_contents, [])
try:
# conda-lock will use `--override-channels` so nodefaults is redundant.
channels.remove("nodefaults")
except ValueError:
pass

return LockSpecification(
dependencies={platform: dependencies for platform in platforms},
channels=get_in(["tool", "conda-lock", "channels"], toml_contents, []),
channels=channels,
sources=[path],
allow_pypi_requests=get_in(
["tool", "conda-lock", "allow-pypi-requests"], toml_contents, True
Expand Down

0 comments on commit 60991f4

Please sign in to comment.