Friday, January 27, 2012

Package dependency hell

I thought that dependency issues are a things of the past. I mean it is the 21st century after all. Well not so fast. Today I had the pleasure to spend 20 minutes to install python-ldap. One of my iPhone app project is a Point of Sale app. It connects to the backend for categories, products, and user login and uses the company's LDAP server for authentication.
Simple task isn't it... not so fast. Backend server running Ubuntu linux. I am writing all my server code in Python using the Django framework.

Let's see what we need to accomplish it:
Started by running pip install django-auth-ldap... Success. to install into the virtual environment. Installs without issue, nice. Next lets boot up the Python shell and try to import it and do some testing... Failed. Gives me a nice message that it's missing python-ldap. No problem lets jump out of the Python shell.Run pip install python-ldap... Big fat fail "error: command 'gcc' failed with exit status 1". I've been doing C coding for awhile to know that's not a good sign. First I though it maybe a virtuelenv issue so I tried it with the package manager, sudo apt-get install python-ldap... Failed. WTF!! How can it be?! I mean if Ubuntu does not know how to install it properly then who can?

Well I have been using Linux since '94 and no I do not have gray beard or beer belly. Looked up how can apt-get check metadata, found build-dep. Super. Lets run it again sudo apt-get build-dep python-ldap... Success. Long behold it found an other 55MB worth of packages it needs. Gave it 'Y' to install and after a few seconds I got my shiny python-ldap up and running. What I don't get is why on earth Ubuntu doesn't do this by default, or at least give me the option after a failed attempt.

Thanks to django-auth-ldap good docs the rest is history. Now the app authenticates every user with their LDAP credentials and marks all their sales. Sweet :D