views:

580

answers:

6

I'm starting Django development, and I can either install it from the .deb using

$ apt-get install python-django

on my Ubuntu machine, or I can download the .tar.gz from djangoproject.com, and start with that.

What are the benefits and drawbacks of each approach?

+4  A: 

Using apt-get you'll get better uninstall support via the package manager and it can also install dependencies for you. If you install with apt-get you might get automatic updates, which is very nice for security patches.

With the tar you might get a newer version and you might get the opportunity to tailor the compile flags. A build could be more optimized for your particular processor, but since it's python that doesn't matter in this case.

Lone Coder
+7  A: 

Using apt-get lets your system keep track of the install (e.g. if you want to disinstall, upgrade, or the like, late). Installing from source (.tar.gz or otherwise) puts you in charge of what's what and where -- you can have multiple versions installed at various locations, etc, but there's no easy "uninstall" and the like. Personally I prefer to install by my OS's supported method (apt-get and the like) for packages I think as secondary or auxiliary, directly from svn/hg/&c for ones I'm contributing to or otherwise want to keep the closest control on, and .tar.gz (or better when available .tar.bz2;-) "snapshots" and "source releases" that are s/where in the middle...

Alex Martelli
And how do u map the source to Env, Symbolic links?
Lakshman Prasad
ln -s makes symbolic links -- if I need to set environment variables I do that in .profile, .bashrc, /etc/profile, or /etc/bashrc.
Alex Martelli
A: 

I've always installed using the dev version. (Instructions)

This makes updating really easy and gives you all the fancy features in the /dev/ docs. I would suggest you try going this route if possible (if anything it gives you an idea of how site-packages work).

Note: ubuntu 9.04's recent move to dist-packages from site-packages (8.04) made this a bit confusing, had to recreate the link.

lostincode
+5  A: 

The best way to install is to check out the code, which ever the changeset (branch/tag) you want, and define a symbolic link to it

Checkout the version you want:

# For trunk
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk   
# For a tag, 1.02 release
svn co http://code.djangoproject.com/svn/django/tag/1.02 django-1.02
# To update the trunk
cd django-trunk
svn up

Then define symbolic link

ln -fs /usr/lib/python2.5/site-packages/django/* ~/django-1.02/

If you want to test your code in the latest release, just redefine the symbolic link:

ln -fs /usr/lib/python2.5/site-packages/django/* ~/django-trunk/

The package managers aptitude and apt-get are good for auto updating those software you don't really bother about developing with every day, like media players, browsers. For stuff U code with everyday, full control of versions is needed, you get that only by source.

Lakshman Prasad
+1 Most Django devs are "tracking trunk", I believe. The only Python software on my computer that is installed via the package manager is python itself. Everything else via source or easy_install. And I always use virtualenv.
codeape
You've got 'svn co' twice for some reason in both lines.
Daniel Roseman
@Daniel Fixed the typo.
Lakshman Prasad
A: 

I know with debian and probably some other distros, the version of django in the package manager is the 0.9 branch, not the 1.X branch. Definately something you want to avoid.

That's not right: Debian 5.0 shipped with Django 1.0.2 (http://packages.debian.org/lenny/python-django).
conny
Should have been more specific, Debian 4.0 (etch) still uses the 0.9 branch - http://packages.debian.org/etch/python-django
A: 

Getting Django from your Ubuntu repository gives you the older "stable" version. This may be fine with you, but I believe most developers prefer sticking with latest code available in the trunk to get more features.

IMHO the cleanest solution is not to install .tar.gz/SVN version with straightforward sudo python setup.py install (or use easy-install) but to make a .deb package. This way you should get the maximum benefits: 1) all the bleeding edge features you want 2) proper Debian/Ubuntu package, which you may easily uninstall, upgrade and deploy to any number of Debian machines.

Here's a quick and dirty way how to do it:

#
# This is dirty (you have been warned) way to quickly
# make new Django .deb package from SVN trunk for personal use.
#
apt-get source python-django
apt-get build-dep python-django
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
DJANGO_SVN_REVISION=`LC_ALL=C svn info django-trunk \
                     | grep ^Revision: | awk '{ print $2 }'`
cp -R python-django-*/debian django-trunk/
cd django-trunk
dch --newversion=1.1-1ubuntu1~svn${DJANGO_SVN_REVISION} \
    "Non-maintainer quick-and-dirty update to SVN r${DJANGO_SVN_REVISION}"
dpkg-buildpackage
# Have a good sip of tea, coffee or whatever you prefer.
# Because of tests, this is going to take quite a while.
# You may consider disabling (this is bad!) tests by commenting out
# line mentioning "runtests.py" in debian/rules.
cd ..
dpkg -i python-django_*.deb

This is not even really guarranteed to work (and I'm not really sure even about proper package version naming), but I've tried it myself and it worked for me.

drdaeman