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

2

8

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?

Monde answered 29/9, 2011 at 9:26 Comment(1)
Recommended: blip.tv/djangocon/taming-dependencies-with-pip-5582996Galingale
A
19

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.

Arsenopyrite answered 29/9, 2011 at 10:4 Comment(0)
M
0

I found one in django's website:

https://code.djangoproject.com/wiki/best-practices-to-work-with-3rd-party-apps-and-making-yours-portable

Looks like he is suggesting what I listed in question as option #2.

Monde answered 29/9, 2011 at 9:45 Comment(1)
I do like keeping them in a local directory, so that I can easily modify them as needed and everything is in one place when moved.Domenech

© 2022 - 2024 — McMap. All rights reserved.