mirror of
https://github.com/docker/compose.git
synced 2025-07-24 06:04:57 +02:00
Merge pull request #1957 from aanand/stub-run-on-windows
WIP: Build Windows binary
This commit is contained in:
commit
aa70209ade
@ -8,7 +8,6 @@ import sys
|
|||||||
from inspect import getdoc
|
from inspect import getdoc
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
import dockerpty
|
|
||||||
from docker.errors import APIError
|
from docker.errors import APIError
|
||||||
from requests.exceptions import ReadTimeout
|
from requests.exceptions import ReadTimeout
|
||||||
|
|
||||||
@ -31,6 +30,11 @@ from .log_printer import LogPrinter
|
|||||||
from .utils import get_version_info
|
from .utils import get_version_info
|
||||||
from .utils import yesno
|
from .utils import yesno
|
||||||
|
|
||||||
|
WINDOWS = (sys.platform == 'win32')
|
||||||
|
|
||||||
|
if not WINDOWS:
|
||||||
|
import dockerpty
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
console_handler = logging.StreamHandler(sys.stderr)
|
console_handler = logging.StreamHandler(sys.stderr)
|
||||||
|
|
||||||
@ -337,6 +341,14 @@ class TopLevelCommand(Command):
|
|||||||
"""
|
"""
|
||||||
service = project.get_service(options['SERVICE'])
|
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']:
|
if options['--allow-insecure-ssl']:
|
||||||
log.warn(INSECURE_SSL_WARNING)
|
log.warn(INSECURE_SSL_WARNING)
|
||||||
|
|
||||||
@ -351,7 +363,7 @@ class TopLevelCommand(Command):
|
|||||||
)
|
)
|
||||||
|
|
||||||
tty = True
|
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
|
tty = False
|
||||||
|
|
||||||
if options['COMMAND']:
|
if options['COMMAND']:
|
||||||
@ -362,8 +374,8 @@ class TopLevelCommand(Command):
|
|||||||
container_options = {
|
container_options = {
|
||||||
'command': command,
|
'command': command,
|
||||||
'tty': tty,
|
'tty': tty,
|
||||||
'stdin_open': not options['-d'],
|
'stdin_open': not detach,
|
||||||
'detach': options['-d'],
|
'detach': detach,
|
||||||
}
|
}
|
||||||
|
|
||||||
if options['-e']:
|
if options['-e']:
|
||||||
@ -409,7 +421,7 @@ class TopLevelCommand(Command):
|
|||||||
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if options['-d']:
|
if detach:
|
||||||
service.start_container(container)
|
service.start_container(container)
|
||||||
print(container.name)
|
print(container.name)
|
||||||
else:
|
else:
|
||||||
|
@ -66,7 +66,12 @@ def call_silently(*args, **kwargs):
|
|||||||
Like subprocess.call(), but redirects stdout and stderr to /dev/null.
|
Like subprocess.call(), but redirects stdout and stderr to /dev/null.
|
||||||
"""
|
"""
|
||||||
with open(os.devnull, 'w') as shutup:
|
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():
|
def is_mac():
|
||||||
|
24
script/build-windows.ps1
Normal file
24
script/build-windows.ps1
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user