Thursday, May 7, 2009

Temporarily using a different python version on Debian/Ubuntu

On my Ubuntu 9.04 box, python 2.4, 2.5 and 2.6 are installed. 2.6 is used by default. repo, the android git wrapper script requires python 2.5. If you use 2.6, you get the following nasty error:

/home/jerome/Code/OSS/android/.repo/repo/codereview/proto_client.py:19: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5
Traceback (most recent call last):
File "/home/jerome/Code/OSS/android/.repo/repo/main.py", line 34, in
from manifest import Manifest
File "/home/jerome/Code/OSS/android/.repo/repo/manifest.py", line 21, in
from project import Project, MetaProject, R_HEADS
File "/home/jerome/Code/OSS/android/.repo/repo/project.py", line 27, in
from gerrit_upload import UploadBundle
File "/home/jerome/Code/OSS/android/.repo/repo/gerrit_upload.py", line 21, in
from codereview.proto_client import HttpRpc, Proxy
File "/home/jerome/Code/OSS/android/.repo/repo/codereview/proto_client.py", line 31, in
from need_retry_pb2 import RetryRequestLaterResponse;
File "/home/jerome/Code/OSS/android/.repo/repo/codereview/need_retry_pb2.py", line 9, in
from froofle.protobuf import descriptor_pb2
File "/home/jerome/Code/OSS/android/.repo/repo/froofle/protobuf/descriptor_pb2.py", line 879, in
class FileDescriptorSet(message.Message):
File "/home/jerome/Code/OSS/android/.repo/repo/froofle/protobuf/reflection.py", line 155, in __init__
superclass.__init__(cls, name, bases, dictionary)
TypeError: Error when calling the metaclass bases
type.__init__() takes 1 or 3 arguments

As I don't want to change the default python version, and until Google comes with a proper repo script, I used the following ugly trick:


ln -s /usr/bin/python2.5 python
export PATH=`pwd`:$PATH


If someone has a better idea, let me know.