mysql - Staying in the same Shell session with Python -


i building python script automatically create , arrange new django projects.

what i'm doing is;

  • create virtualenv
  • activate virtualenv source my_app/bin/activate
  • pip install toolname (multiple times)
  • django startproject
  • django startapp (multiple times)
  • mkdir `dirs (making template dirs, assets, etc.)
  • open ./my_app/my_app/settings.py , edit inners (based on script's input)
  • open ./my_app/my_app/urls.py , edit (unlock) admin portion
  • create default admin.py , urls.py files apps
  • auto-download latest javascript libraries, images etc.

now issue want python's shell (os.system('source my_app/bin/activate')) keep it's session, enter virtual environment , can pip install python script.

now when do;

os.system('virtualenv ' + virtualenv_name) os.system('source ' + ve_path + 'bin/activate') os.system('which python') 

it still tells me it's in /bin/python should in /path/to/my_app/bin/python.

does know if there native way (so teammates don't have install more virtualenv in main environment) keep shell's session alive?

i thinking of chaining multiple commands , concat them 1 shell command, that's kind of ugly.

problem when source bash file, doesn't launch new shell, rather executes in current shell, how can change environment variables there. os.system('source ' + ve_path + 'bin/activate') indeed launches new bash , changed environment variables disappear when shell terminates.

at least on system virtualenv generates activate_this.py file too. line 2 in file explains how use it. it's python version of activate bash code.

try putting in code instead of source line: (oh well, called environment "a", bet got idea now)

activate_this = 'a/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -