开发者

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

开发者 https://www.devze.com 2023-04-09 10:51 出处:网络
In our project we are using some django reusable apps, we are considering how to make the continuous and automatic deployment easy and painless.

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 "pi开发者_C百科p 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消