I am trying to write a module file for a program that creates a python virtualenv
. In order to start the virtualenv
, it needs to first run /programs/program-env/bin/activate
. How do I do this in a modulefile
?
Any help will be greatly appreciated.
Note: I tried just putting the above line in the file and it didn't work.
Thanks,
Edit:
I am writing a modulefile to load a program that can only run in a virtualenv
. Normally these modulefiles will set variable names and/or add bin directory to path. Since the above package is somewhat different, I don't know how to proceed. An example module file can be found here.
Here is a slightly more complete answer, building on the answers by Donal and betapatch, that allows you to swap between two modules which do similar things:
Firstly, you need to use
source .../activate
rather than just.../activate
.Secondly,
modules
has some horrible logic whenswap
ping modules. If you want tomodule swap foo bar
(removefoo
and loadbar
in its place), it actually does the following:This means that if
foo
andbar
are both modulefiles using virtualenvs, the secondfoo remove
willdeactivate
bar
.