I was getting the following build error on some machines, but not on others, and they were all running Ubuntu 16.04.1
File "/usr/lib/python2.7/dist-packages/setuptools/command/build_ext.py", line 175, in build_extension
if ext._needs_stub:
AttributeError: Extension instance has no attribute '_needs_stub'
It turns out that the difference was that some had setuptools installed from apt, which was bringing in version 20 or so, and some had a modern version that I had installed with pip install.
The former failed, the latter succeeded.
I hope this saves somebody some hair-tearing.