Workarounds for install errors on Windows (#21890)

1. Forwarding sys.stdin, e.g. use input_multiprocess_fd,
gives an error on Windows. Skipping for now

3.  subprocess_context needs to serialize for Windows, like it does
for Mac.

Co-authored-by: lou.lawrence@kitware.com <lou.lawrence@kitware.com>
Co-authored-by: John Parent <john.parent@kitware.com>
This commit is contained in:
Betsy McPhail 2021-10-21 16:30:16 -04:00 committed by Peter Scheibel
parent 81bc00d61f
commit b60a0eea01
4 changed files with 43 additions and 24 deletions

View File

@ -6,11 +6,9 @@
from __future__ import unicode_literals
import contextlib
import fcntl
import os
import struct
import sys
import termios
import textwrap
import traceback
from datetime import datetime
@ -18,6 +16,11 @@
import six
from six import StringIO
from six.moves import input
from sys import platform as _platform
if _platform != "win32":
import fcntl
import termios
from llnl.util.tty.color import cescape, clen, cprint, cwrite
@ -370,22 +373,28 @@ def hline(label=None, **kwargs):
def terminal_size():
"""Gets the dimensions of the console: (rows, cols)."""
def ioctl_gwinsz(fd):
try:
rc = struct.unpack('hh', fcntl.ioctl(
fd, termios.TIOCGWINSZ, '1234'))
except BaseException:
return
return rc
rc = ioctl_gwinsz(0) or ioctl_gwinsz(1) or ioctl_gwinsz(2)
if not rc:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
rc = ioctl_gwinsz(fd)
os.close(fd)
except BaseException:
pass
if not rc:
rc = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
if _platform != "win32":
def ioctl_gwinsz(fd):
try:
rc = struct.unpack('hh', fcntl.ioctl(
fd, termios.TIOCGWINSZ, '1234'))
except BaseException:
return
return rc
rc = ioctl_gwinsz(0) or ioctl_gwinsz(1) or ioctl_gwinsz(2)
if not rc:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
rc = ioctl_gwinsz(fd)
os.close(fd)
except BaseException:
pass
if not rc:
rc = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
return int(rc[0]), int(rc[1])
return int(rc[0]), int(rc[1])
else:
# return shutil.get_terminal_size()
# TODO: find python 2 compatible module to get terminal size
rc = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
return int(rc[0]), int(rc[1])

View File

@ -1135,7 +1135,7 @@ def child_fun():
try:
# Forward sys.stdin when appropriate, to allow toggling verbosity
if sys.stdin.isatty() and hasattr(sys.stdin, 'fileno'):
if sys.platform != "win32" and sys.stdin.isatty() and hasattr(sys.stdin, 'fileno'):
input_fd = os.dup(sys.stdin.fileno())
input_multiprocess_fd = MultiProcessFd(input_fd)

View File

@ -27,7 +27,8 @@
import spack.repo
import spack.store
_serialize = sys.version_info >= (3, 8) and sys.platform == 'darwin'
_serialize = sys.platform == 'win32' or (sys.version_info >= (3, 8)
and sys.platform == 'darwin')
patches = None

View File

@ -10,12 +10,19 @@
from os import O_NONBLOCK
from os.path import basename
from subprocess import PIPE, Popen
from sys import platform as _platform
from sys import stdout
from llnl.util import tty
from spack import *
if _platform != 'win32':
from fcntl import F_GETFL, F_SETFL, fcntl
from os import O_NONBLOCK, rename
else:
from os import rename
re_optline = re.compile(r'\s+[0-9]+\..*\((serial|smpar|dmpar|dm\+sm)\)\s+')
re_paroptname = re.compile(r'\((serial|smpar|dmpar|dm\+sm)\)')
re_paroptnum = re.compile(r'\s+([0-9]+)\.\s+\(')
@ -27,9 +34,11 @@
def setNonBlocking(fd):
"""
Set the given file descriptor to non-blocking
Non-blocking pipes are not supported on windows
"""
flags = fcntl(fd, F_GETFL) | O_NONBLOCK
fcntl(fd, F_SETFL, flags)
if _platform != 'win32':
flags = fcntl(fd, F_GETFL) | O_NONBLOCK
fcntl(fd, F_SETFL, flags)
def collect_platform_options(stdoutpipe):