Skip to content

Commit

Permalink
Merge pull request docker#4383 from shin-/4344-detect-docker-py
Browse files Browse the repository at this point in the history
Detect conflicting version of the docker python SDK
  • Loading branch information
shin- authored Jan 30, 2017
2 parents e05a9f4 + 5895d8b commit 76d4f5b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions compose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@
from inspect import getdoc
from operator import attrgetter


# Attempt to detect https://github.com/docker/compose/issues/4344
try:
# A regular import statement causes PyInstaller to freak out while
# trying to load pip. This way it is simply ignored.
pip = __import__('pip')
pip_packages = pip.get_installed_distributions()
if 'docker-py' in [pkg.project_name for pkg in pip_packages]:
from .colors import red
print(
red('ERROR:'),
"Dependency conflict: an older version of the 'docker-py' package "
"is polluting the namespace. "
"Run the following command to remedy the issue:\n"
"pip uninstall docker docker-py; pip install docker",
file=sys.stderr
)
sys.exit(1)
except ImportError:
# pip is not available, which indicates it's probably the binary
# distribution of Compose which is not affected
pass


from . import errors
from . import signals
from .. import __version__
Expand Down

0 comments on commit 76d4f5b

Please sign in to comment.