Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions compose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from inspect import getdoc
from operator import attrgetter

import dockerpty
from docker.errors import APIError
from requests.exceptions import ReadTimeout

Expand All @@ -31,6 +30,11 @@
from .utils import get_version_info
from .utils import yesno

WINDOWS = (sys.platform == 'win32')

if not WINDOWS:
import dockerpty

log = logging.getLogger(__name__)
console_handler = logging.StreamHandler(sys.stderr)

Expand Down Expand Up @@ -335,6 +339,14 @@ def run(self, project, options):
"""
service = project.get_service(options['SERVICE'])

detach = options['-d']

if WINDOWS and not detach:
raise UserError(
"Interactive mode is not yet supported on Windows.\n"
"Please pass the -d flag when using `docker-compose run`."
)

if options['--allow-insecure-ssl']:
log.warn(INSECURE_SSL_WARNING)

Expand All @@ -349,7 +361,7 @@ def run(self, project, options):
)

tty = True
if options['-d'] or options['-T'] or not sys.stdin.isatty():
if detach or options['-T'] or not sys.stdin.isatty():
tty = False

if options['COMMAND']:
Expand All @@ -360,8 +372,8 @@ def run(self, project, options):
container_options = {
'command': command,
'tty': tty,
'stdin_open': not options['-d'],
'detach': options['-d'],
'stdin_open': not detach,
'detach': detach,
}

if options['-e']:
Expand Down Expand Up @@ -407,7 +419,7 @@ def run(self, project, options):

raise e

if options['-d']:
if detach:
service.start_container(container)
print(container.name)
else:
Expand Down
7 changes: 6 additions & 1 deletion compose/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def call_silently(*args, **kwargs):
Like subprocess.call(), but redirects stdout and stderr to /dev/null.
"""
with open(os.devnull, 'w') as shutup:
return subprocess.call(*args, stdout=shutup, stderr=shutup, **kwargs)
try:
return subprocess.call(*args, stdout=shutup, stderr=shutup, **kwargs)
except WindowsError:
# On Windows, subprocess.call() can still raise exceptions. Normalize
# to POSIXy behaviour by returning a nonzero exit code.
return 1


def is_mac():
Expand Down
24 changes: 24 additions & 0 deletions script/build-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$ErrorActionPreference = "Stop"
Set-PSDebug -trace 1

# Remove virtualenv
if (Test-Path venv) {
Remove-Item -Recurse -Force .\venv
}

# Remove .pyc files
Get-ChildItem -Recurse -Include *.pyc | foreach ($_) { Remove-Item $_.FullName }

# Create virtualenv
virtualenv .\venv

# Install dependencies
.\venv\Scripts\easy_install "http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win32-py2.7.exe/download"
.\venv\Scripts\pip install -r requirements.txt
.\venv\Scripts\pip install -r requirements-build.txt
.\venv\Scripts\pip install .

# Build binary
.\venv\Scripts\pyinstaller .\docker-compose.spec
Move-Item -Force .\dist\docker-compose .\dist\docker-compose-Windows-x86_64.exe
.\dist\docker-compose-Windows-x86_64.exe --version