BUG: fix issue with distutils.exec_command introduced in 1.7.0.

This should fix the PR #3127 to pass all tests.