Skip to content
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

support nodefaults in environment.yml specs #418

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conda_lock/src_parser/environment_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ def parse_environment_file(

env_yaml_data = yaml.safe_load(content)
channels: List[str] = env_yaml_data.get("channels", [])
try:
# conda-lock will use `--override-channels` so nodefaults is redundant.
channels.remove("nodefaults")
except ValueError:
pass

# These extension fields are nonstandard
category: str = env_yaml_data.get("category") or "main"
Expand Down
5 changes: 5 additions & 0 deletions tests/test-env-nodefaults/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- nodefaults
- conda-forge
dependencies:
- python <3.11
10 changes: 10 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ def filter_conda_environment(tmp_path: Path):
return x


@pytest.fixture
def nodefaults_environment(tmp_path: Path):
return clone_test_dir("test-env-nodefaults", tmp_path).joinpath("environment.yml")


@pytest.fixture
def pip_environment(tmp_path: Path):
return clone_test_dir("test-pypi-resolve", tmp_path).joinpath("environment.yml")
Expand Down Expand Up @@ -400,6 +405,11 @@ def test_parse_environment_file_with_pip(pip_environment: Path):
]


def test_parse_env_file_with_no_defaults(nodefaults_environment: Path):
res = parse_environment_file(nodefaults_environment, DEFAULT_PLATFORMS)
assert res.channels == [Channel.from_string("conda-forge")]


def test_parse_env_file_with_filters_no_args(filter_conda_environment: Path):
platforms = parse_platforms_from_env_file(filter_conda_environment)
res = parse_environment_file(filter_conda_environment, platforms)
Expand Down