Use python2 if available; determine num cores. Based on a patch by Rafael Silva.