# deployment: multiple environments - development, test, production

I have deployed (in Webfaction) a development environment for askbot in which I commit everyday's updates from both askbot's repo and few local environments. I want now to create two more environments, a testing one and of course the production one. The three environments will have different source code and different databases, running in the same server in domains like dev.server.com, test.server.com and www.server.com.

I would do this easily for the other 2 environments by following the same instructions but I see that in lib/python2.6 there is a askbot-0.7.40-py2.6.egg folder, so I was wondering that if I install another 2 instances they will override the same folder.

Is this true? How can I prevent this, in order to install three separate environments.

Thanks a lot

edit retag close merge delete

Sort by » oldest newest most voted

The solution for this is just to use virtual environments, so that each one is isolated from the others. To do this, there is a tool virtualenv, easily installed by easy_install virtualenv, and even more easily used by virtualenv <projectNameDir>. This way, nothing is stored on the common site-packages, and files under <projectNameDir> have their own site-packages and are isolated, so you can have many environments in the same server.

Note: When you are inside <projectNameDir> and you run your commands like 'python manegy.py ...' make sure to use python (and any other tools) found at bin folder of your virtual environment. So you will end up running commands like

../bin/python manage.py syncdb


Enjoy!

more

1

You can also activate the virtual environment and then just use "python" command, without the path: source path_to_env/bin/activate.

( 2012-04-21 12:34:01 -0500 )edit

Nice @Evgeny, thanks. And how do I change from environment to environment. I mean, I have multiple environments and there is a folder bin in all of them. Should I run this activate command everytime I want to work on another environment?

( 2012-04-21 12:40:08 -0500 )edit

You can type deactivate too, but there is a tool called virtualenvwrapper that helps switching the environments, I don't really use it though because I don't have a need to switch very often.

( 2012-04-21 12:45:23 -0500 )edit
1

Forgot to mention, my installation did not work, till I changed my django.wsgi file so that sys.path includes also the lib/python2.6 directory of my virtual env. Why should I have done this manually? Did I set up anything wrong? Anyway, now its working!

( 2012-04-21 14:34:24 -0500 )edit