utils: which function addition

* Adds a which function, similar to GNU which. For CPython 3.3+, this is already
included in shutil.py. For older versions it was backported.

* Fixes configuration variables that point to executable paths to use which.

Co-authored-by: Jiri Kuncar <jiri.kuncar@cern.ch>
Signed-off-by: Adrian-Tudor Panescu <adrian.tudor.panescu@cern.ch>