I have a conda environment called hep. I needed to build a package from source i.e. root.cern.ch since I am using some features only avaialble in the master branch.
In order to be able use import ROOT
in the hep environment. I need to source root in my terminal. How can I make conda activate hep
do the sourcing of the package automatically?
To automatically source ROOT setup script whenever you activate hep, you can write a custom activation script, as Conda allows you to run shell commands automatically during activation by creating/modifying an activation script specific to the environment:
mkdir -p ~/anaconda3/envs/hep/etc/conda/activate.d
nano ~/anaconda3/envs/hep/etc/conda/activate.d/source_root.sh
In this file, add the below to source the ROOT installation:
#!/bin/bash
source /path/to/your/root/installation/bin/thisroot.sh
(of course, you can replace "/path/to/your/root/installation/bin/thisroot.sh" with the actual path to the ROOT script you need to sourceThis will automatically source the ROOT setup script whenever "conda activate hep" runs. By placing it in "activate.d" dir, Conda ensures it runs only for hep