Showing posts from May, 2016

Set virtualenv on Python projects

Sometimes we need different python packages versions in different projects. It's like to have 3 computers, and running a different Python project on each computer, and the first project is using Django 1.8, the second project Django 1.7, and the third project Django 1.9.4.

Really I need 3 different computers to do that? Not at all.

Virtualenv is the hero, downloadable from pip, and it make our life easier. It let us to have a lot of Python projects, using their different dependence and versions, all living at the same computer but different environment. Check out the next image.

To install virtualenv, just you need to type:

pip install virtualenv
This line will download, install and config virtualenv and their own dependence.

Now we are enabled to create a new virtual environment over any existing Python project. For this example, we already have a project called "mall4g". We need to browse to the directory and run the command, where "mall4g" is a directory.

How we are deploying Django projects to AWS

Internally, we are constantly looking for the best way to deploy some Django projects to AWS.  Some people prefer to use automated process (yeah! automated deploys).

This is just a step. There are a lot way to do it. Here is the stack. Let's go!

I personally prefer Google Cloud Platform. Probably I will write about that on this blog soon.

I'm using a EC2 instance, with Ubuntu.
I'm clonning the  Git repo under  /home/ubuntu by using the ubuntu user.

Virtual environment is an important requirement. I have used both virtualenv  and virtualenvwrapper; in this case I used virtualenvwrapper, and all Python and pip packages are installed in a separated folder.

Gunicorn is just an HTTP server for
I have started my Django project on server trough Gunicorn on a local hostname and port (http://localhost:8000).

I use Supervisor to convert my project in a daemon. That's it. So, if I restart the server, this daemon will be started automati…