boa
boa copied to clipboard
[FeatureRequest] Automatic generation of basic activate/deactivate scripts
Fairly often I need to create activate/deactivate scripts to do 2 common things:
- Set an env var
- Add an entry to the path
It would be great if these 2 common requirements could be declaratively specified in the recipe.yaml and have boa automatically generate the necessary activate/dectivate scripts
Doing 1 correctly is slightly tricky and very verbose to do manually (particularly for multiple variables). To do it correctly you want to save the original value on activate and restore it on deactivate.
Similarly for 2, adding to the path is easy enough but robustly removing it again on deactivate whilst seamlessly handling other path changes in-between is tedious.
This is the sort of thing automation could (fairly) easily handle and would generally improve the robustness of most activate/deactivate scripts.
@dhirschfeld one approach is https://github.com/mamba-org/multisheller
This has been used in the community, e.g. in this recipe: https://github.com/conda-forge/icub-models-feedstock/blob/main/recipe/activate.msh
It works for exactly the use cases you are describing (special function to add & remove path from PATH and setting / unsetting some env vars).
Also, I imagine most activate/deactivate scripts only work with bash. Automating this process would let you use multisheller to ensure conda packages worked for all shells.
one approach is https://github.com/mamba-org/multisheller
Yep - my thoughts exactly! 😄
...it would just be nice if you could somehow automate the generation of the activate/deactivate scripts - e.g.
env_vars:
- DOTNET_ROOT: {{ PREFIX }}/dotnet
...and have that automatically generate activate/deactivate scripts for all supported shells
Anyway, just something I've been pondering so I thought I'd write it up for reference.
Prompted by having to maintain 6 env vars and 2 path entries for 3 different shells over in the dotnet feedstock.
I would like to use multisheller for this now, but have only had a quick look at it so far - it's on my TODO list to investigate 😔
This has been used in the community, e.g. in this recipe
Awesome, thanks for the ref! That'll be a huge help in figuring out how to port to multisheller!