[backport:2.6][!10] 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.
See merge request !540 (merged)
(cherry picked from commit 746aa626)
2443bc4a Make Python package detection work with pip 10