Skip to content
Snippets Groups Projects
Commit 79906467 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[!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

(cherry picked from commit 746aa626)

2443bc4a Make Python package detection work with pip 10
parent d96c83fb
No related branches found
No related tags found
2 merge requests!586Centralize CI config for 2.6 release,!541[backport:2.6][!10] Make Python package detection work with pip 10
Pipeline #10327 passed
......@@ -21,11 +21,11 @@ if hasattr(module, '__version__'):
# Alternative implementation: through pip (pip itself implement pip.__version__,
# so we never get here, when checking the version of pip itself), only works if
# package name and distribution name are the same
import pip
for package in pip.get_installed_distributions():
import pkg_resources
for package in pkg_resources.working_set:
if package.project_name == modstr and package.has_version():
sys.stdout.write(package.version)
sys.exit(0)
# Give up on this one
sys.exit(1)
\ No newline at end of file
sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment