Make Python package detection work with pip 10
pip 10 moved several interfaces to an internal package, causing our pyversion.py script to fail. This patches fixes the issue by getting installed distributions directly from setuptools, as suggested in https://github.com/pypa/pip/issues/5243.