I want to write a python package installing a script in Python in virtualenv. I am writing a function to install virtualenv
def prepareRadioenv():
if not os.path.exists('radioenv'):
print 'Create radioenv'
system('easy_install virtualenv')
system('virtualenv --no-site-package radioenv')
print 'Activate radioenv'
system('source radioenv/bin/activate')
I am trying to use "source radioenv / bin / activate" to activate a virtual environment, unfortunately os.system creates a subprocess to execute the command. The environment change made by activation disappears with the subprocess, this does not affect the Python process. This raises the problem, how can I execute some context-sensitive sequence of commands in Python?
Another example:
system("cd foo")
system("./bar")
Here cd does not affect the next system (". Bar"). How to make this environment context live in different teams?
Is there something like a context sensitive shell? So I can write Python code like this:
shell = ShellContext()
shell.system("cd bar")
shell.system("./configure")
shell.system("make install")
if os.path.exists('bar'):
shell.system("remove")
Thank.