I wanted to start out with some wxPython GUI testing and was trying to get dogtail installed on my Ubuntu 10.04 system. The current dogtail version that you can install with Synaptic is 0.6.1, while I want to try out 0.7.0. So I grabbed the source from dogtail’s website, unpacked it into /usr/local/src and ran:
$ cd /usr/local/src/dogtail-0.7.0$ sudo setup.py install
However, when I tried to run sniff for example, it can’t find it’s image files, because it’s looking explicitly in /usr/share instead of /usr/local/share. Ok, so let’s try again:
$ sudo setup.py install --prefix=/usr
This time, sniff starts complaining that there’s no module named dogtail.config. The problem seems to be that instead of installing into dist-packages, with a prefix other than /usr/local, the package files will be installed in site-packages. A bit of Googling tells me that Ubuntu doesn’t have /usr/lib/pythonx.y/site-packages in its path by default. Only dist-packages inside /usr/local/lib/pythonx.y and in /usr/lib/pythonx.y are added to Python’s system path by default (see this launchpad bug for more information).
Now luckily enough there’s a special argument for distutils if you want to install a “distribution” package manually, namely --install-layout=deb. Passing this argument will put the package using /usr as prefix and using dist-packages instead of site-packages, as if you were installing a deb package. So:
$ sudo setup.py install --install-layout=deb
That did the trick for me. Now back to what I was originally wanting to figure out: wxPython GUI scripting and testing with dogtail.
Edit: an anonymous user pointed out to me that no site-packages directory is in Python’s system path by default; he’s right, I revisited the issue and my post, and it is the --prefix=/usr which is the problem. Ubuntu’s distutils will put custom installed packages in /usr/local/lib/pythonx.y/dist-packages automatically, but when you use a different prefix, the default behavior is to use site-packages. That’s why you shouldn’t use --prefix=/usr, but --install-layout=deb instead.