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.
You have not explained very clearly what you are trying to do but given your mention of a tcl script in the title I will assume you are writing a Tcl script that needs to load the virtualenv environment to manipulate python script using the virtualenv configuration. The activate scripts are bash scripts that ultimately setup the current environment. You cannot simply source these into Tcl as Tcl is not a Bourne shell. However you can create a shell subprocess and read its environment and compare this with the environment as changed following sourcing the activate script. If your tcl script applies the differences to its own environment the resulting Tcl process will be equivalent to the bash shell after sourcing the activate script.
Here is an example. If your run this as
tclsh scriptname bin/activateit prints the environment which will now include the additional settings from the activate script. In my test on a linux box this added a VIRTUAL_ENV variable and modified PS1 and PATH.