conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
470 stars 102 forks source link

Default platforms are unexpectedly added from multiple sources #337

Closed maresb closed 1 year ago

maresb commented 1 year ago

Checklist

What happened?

If I use both pyproject.toml and a supplemental environment.yml as sources, and if I specify platforms in pyproject.toml but not in environment.yml, I would expect the resulting platforms to be the list from pyproject.toml. Instead it's those platforms union the default platforms (linux-64, osx-64, win-64).

The logic in parse_source_files looks odd to me. It seems like we add the default platforms if they are missing from any source file (except for pyproject.toml?).

I would have expected that we take the union of all platforms from all source files, and then substitute the default platforms only if that were empty.

Ping @srilman since this involves code we've been looking at recently.

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

srilman commented 1 year ago

I agree, this is really odd behavior. I think this is because for Conda source files like meta.yaml and environment.yml files, we need to know the list of platforms before we actually start parsing the file in order for OS preprocessor selectors to work correctly. However, as I think you suggested in https://github.com/conda/conda-lock/issues/278#issuecomment-1371407231, what we should really do is parse the source files once to get the platforms, and then parse them again to get the list of dependencies.

srilman commented 1 year ago

Since we were planning to split #316 into smaller pieces anyways, I think I can do the following to get this problem fixed first: