Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Django have an equivalent of Rails's "bundle install"?

Tags:

python

django

One thing I like about Rails projects is that when deploying to a remote server, if everything is set up correctly you can just do:

$: bundle install

And the system will install the various dependencies (ruby gems) needed to run the project.

Is there something similar for Python/Django?

like image 284
nemesisdesign Avatar asked Aug 22 '12 08:08

nemesisdesign


2 Answers

You can freeze requirements. This generates a list of all the Python modules that your project needs. I believe bundle is similar in concept.

For example:

virtualenv --no-site-packages myproject_env # create a blank Python virtual environment
source myproject_env/bin/activate # activate it
(myproject_env)$ pip install django # install django into the virtual environment
(myproject_env)$ pip install other_package # etc.
...
(myproject_env)$ pip freeze > requirements.txt

The last line generates a text file will all the packages that were installed in your custom environment. You can use that file to install the same requirements on other servers:

pip install -r requirements.txt

Of course you don't need to use pip, you can create the requirements file by hand; it doesn't have any special syntax requirements. Just a package and (possibly) version identifier on each line. Here is a sample of a typical django project with some extra packages:

Django==1.4
South==0.7.4
Werkzeug==0.8.3
amqplib==1.0.2
anyjson==0.3.1
celery==2.5.1
django-celery==2.5.1
django-debug-toolbar==0.9.4
django-extensions==0.8
django-guardian==1.0.4
django-picklefield==0.2.0
kombu==2.1.4
psycopg2==2.4.5
python-dateutil==2.1
six==1.1.0
wsgiref==0.1.2
xlwt==0.7.3
like image 189
Burhan Khalid Avatar answered Sep 24 '22 03:09

Burhan Khalid


The closest is probably virtualenv, pip and a requirements file. With those 3 ingredients is quite easy to write a simple bootstrap scripts.

More demanding and complex is buildout. But I would only go for it if virtualenv and pip are not sufficient.

And if you extend this approach with fabric and optional cuisine, you already have your project deployment automated. Check out these links for more information:

  • http://www.caktusgroup.com/blog/2010/04/22/basic-django-deployment-with-virtualenv-fabric-pip-and-rsync/
  • http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/
  • http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/
like image 38
schacki Avatar answered Sep 20 '22 03:09

schacki