Can I set environment variables in environment.yml
files in conda environments?
Conda lets me save environment variables in environments via the env_vars.sh
script, but is there a way to automate the process of creating env_vars.sh
files in the activate.d
, deactivate.d
directories according to some specification of environment variables within environment.yml
, for a reproducible environment with, say, MKL_THREADING_LAYER=GNU
?
Current Status (Conda v4.7.12)
No, it is not possible to set env-specific environment variables in an env YAML.
Outlook: Perhaps in Conda v4.8
As @Ben pointed out in comments, this has been an open feature request. While it technically doesn't have a milestone set, a pull request referencing this issue was merged as part of milestone Conda v4.8.0 that looks like it provides some infrastructure for env-specific environment variables (i.e., without manually writing activation hooks). For example, the PR adds a
conda-env
commandvars
that can be used likeHowever, I could find neither code for parsing vars from a YAML nor new code for exporting vars to a YAML (but, admittedly, I only skimmed through it - mainly looking at the tests that were added).
In summary, the final answer is still not yet, but it could be on the horizon.