Skip to content
Snippets Groups Projects

Make Python package detection work with pip 10

Merged Steffen Müthing requested to merge bug/fix-python-package-detection-with-pip-10 into master
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
@@ -21,11 +21,11 @@ if hasattr(module, '__version__'):
@@ -21,11 +21,11 @@ if hasattr(module, '__version__'):
# Alternative implementation: through pip (pip itself implement pip.__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
# so we never get here, when checking the version of pip itself), only works if
# package name and distribution name are the same
# package name and distribution name are the same
import pip
import pkg_resources
for package in pip.get_installed_distributions():
for package in pkg_resources.working_set:
if package.project_name == modstr and package.has_version():
if package.project_name == modstr and package.has_version():
sys.stdout.write(package.version)
sys.stdout.write(package.version)
sys.exit(0)
sys.exit(0)
# Give up on this one
# Give up on this one
sys.exit(1)
sys.exit(1)
\ No newline at end of file
Loading