Mockito and python3

In case you use mockito, you have probably noticed that it won’t install on python 3 anymore. Let’s check it out in a vagrant box.

vagrant ssh
Last login: Fri Dec 27 11:00:09 2013 from

[vagrant@localhost ~]$ sudo pacman -Sy
:: Synchronizing package databases...
[vagrant@localhost ~]$ sudo pacman -S python-pip
resolving dependencies...
looking for inter-conflicts...

Packages (3): python-3.3.3-1  python-setuptools-2.0.1-1  python-pip-1.4.1-2

Total Download Size:    12.55 MiB
Total Installed Size:   87.56 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages ...

[vagrant@localhost ~]$ sudo pip install mockito
Downloading/unpacking mockito
  Downloading mockito-0.5.2.tar.gz
  Running egg_info for package mockito
    error: invalid command 'bdist_egg'
    Traceback (most recent call last):
      File "./", line 143, in use_setuptools
        raise ImportError
OSError: Could not build the egg.

Cleaning up...
Command python egg_info failed with error code 1 in /tmp/pip_build_root/mockito
Storing complete log in /root/.pip/pip.log

Obviously it is pulling distribute 0.6.10. Doesn’t sound very bleeding edge (current distribute is 0.7.3 and that is just a wrapper since setuptools and distribute have been merged).

Why is it pulling that version specifically?

[vagrant@localhost ~]$ wget
[vagrant@localhost ~]$ tar xzvf mockito-0.5.2.tar.gz
[vagrant@localhost ~]$ cd mockito-0.5.2
[vagrant@localhost mockito-0.5.2]$ grep -Hirn "0.6.10" * = "0.6.10"
[vagrant@localhost mockito-0.5.2]$ grep use_setuptools 
from distribute_setup import use_setuptools

Basically distribute_setup is a bootstrapping script for distribute that will download distribute. If you don’t provide a version kwarg to use_setuptools then it will download the default which is a hardcoded “0.6.10”.

What you can do

Replace your mockito dependency with mockito-without-hardcoded-distribute-version. You don’t need to touch your imports. I basically just changed the name and removed the distribute_setup stuff.

Also, comment on the pull request so that it gets merged.

comments powered by Disqus