diff --git a/compose/cli/main.py b/compose/cli/main.py index 890a3c37177..21b559aa3b9 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -8,7 +8,6 @@ from inspect import getdoc from operator import attrgetter -import dockerpty from docker.errors import APIError from .. import __version__ @@ -28,6 +27,9 @@ from .utils import get_version_info from .utils import yesno +if sys.platform != 'win32': + import dockerpty + log = logging.getLogger(__name__) console_handler = logging.StreamHandler(sys.stderr) @@ -65,6 +67,14 @@ def main(): except NeedsBuildError as e: log.error("Service '%s' needs to be built, but --no-build was passed." % e.service.name) sys.exit(1) + except AttributeError as e: + if sys.platform == 'win32': + if str(e) == "'module' object has no attribute 'AF_UNIX'": + log.error('No docker host environment variables specified. ' + 'Run docker-machine env --help for more info.') + sys.exit(1) + else: + raise def setup_logging(): @@ -393,6 +403,13 @@ def run(self, project, options): if options['-d']: service.start_container(container) print(container.name) + elif sys.platform == 'win32': + raise UserError( + 'Only detached mode is supported on Windows. You must run ' + 'compose with the -d option. If you wish to help getting ' + 'terminal mode support working, PRs are welcome! We need to ' + 'replace dockerpty or remove its depedency on fcntl.' + ) else: dockerpty.start(project.client, container.id, interactive=not options['-T']) exit_code = container.wait() diff --git a/setup.py b/setup.py index 33335047bca..b567da45507 100644 --- a/setup.py +++ b/setup.py @@ -34,11 +34,13 @@ def find_version(*file_paths): 'texttable >= 0.8.1, < 0.9', 'websocket-client >= 0.32.0, < 1.0', 'docker-py >= 1.3.1, < 1.4', - 'dockerpty >= 0.3.4, < 0.4', 'six >= 1.3.0, < 2', 'jsonschema >= 2.5.1, < 3', ] +if (sys.platform != 'win32'): + install_requires.append('dockerpty >= 0.3.4, < 0.4') + tests_require = [ 'nose',