I would like to write a script to invoke a Python program. I have dabbled in bash and fish, but as the script logic becomes more complex (using Git, etc, etc), I'm leaning increasingly towards using Python. (Both the program and script would be Python 2.7 on Ubuntu 14.04)
However, I have some strong requirements for invoking:
- a custom PYTHONPATH must be set (the same every time)
- a virtualenv is required (may change based on user input/logic)
- program arguments are required (may change based on user input/logic)
The bash equivalent is this:
~$ pew workon <VIRTUALENV>
~$ export PYTHONPATH=</PROGRAM/PATH>
~$ python -m <MODULE.MODULE> --<ARGUMENT> --<ARGUMENT>=<VALUE>
As you can see I use pew to activate my virtualenv rather than virtualenvwrapper or calling the activate script directly. But I'm happy to use any virtualenv library.
Alternatively, is this impossible? (In which case I could write a thin shell wrapper to set the environment, but how do I make the python -m MODULE --ARGUMENT
call?)