Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best practice to deploy (manage dependency) the django reusable apps in a real production project?

In our project we are using some django reusable apps, we are considering how to make the continuous and automatic deployment easy and painless.

We have 2 options:

option#1: use "pip install xxx" to install all dependencies reusable apps. Write a script to install and check the dependencies.

option#2: make a copy of all used reusable apps under our own directory, so we basically will deploy everything in our project directory.

both options have its pros and cons, I am wondering if you can share your the best practice of doing this?

like image 897
Robert Mao Avatar asked Sep 29 '11 09:09

Robert Mao


People also ask

What is the most easiest fastest and most stable deployment choice in most cases with Django?

If you're new to deploying Django and/or Python, we'd recommend you try mod_wsgi first. In most cases it'll be the easiest, fastest, and most stable deployment choice.


1 Answers

You can create a file of dependencies with pip very easily which will mean that the correct versions of each app will be maintained between servers

# Save dependancies to a file
pip freeze > requirement_file.txt

creates a file something like:

django==1.3
django-tagging
markdown
...

which can be later used to reinstall the listed apps on a different server

# Install all dependencies in the file
pip install -r requirement_file.txt

This is a nice and simple approach. You can get more complicated with the likes of zc.buildout

http://pypi.python.org/pypi/zc.buildout

which helps manage packages (python and non-python) via scripts (you create 'recipes' containing the details of the packages you need installed)

If you need broader control over server installs you could use 'puppet' or 'chef'

http://projects.puppetlabs.com/projects/1/wiki/Big_Picture http://wiki.opscode.com/display/chef/Chef+Server

which are aimed at automating and deploying more than just dependencies, but entire servers

I haven't needed to use more then simple pip requirements files, but the other options are great if you need more.

EDIT

Keeping your own version of the apps in your project root/python path can become cumbersome and difficult to track, I'd suggest using a pip requirement file.

like image 95
Timmy O'Mahony Avatar answered Oct 14 '22 13:10

Timmy O'Mahony