First time here? Check out the FAQ!
2

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

zaf's avatar
512
zaf
asked 2012-04-08 08:12:42 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

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!

zaf's avatar
512
zaf
answered 2012-04-21 11:00:45 -0500
edit flag offensive 0 remove flag delete link

Comments

1

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

Evgeny's avatar Evgeny (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?

zaf's avatar zaf (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.

Evgeny's avatar Evgeny (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!

zaf's avatar zaf (2012-04-21 14:34:24 -0500) edit
add a comment see more comments