summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2021-10-21 16:30:16 -0400
committerPeter Scheibel <scheibel1@llnl.gov>2022-03-17 09:01:01 -0700
commitb60a0eea012587acef308d6df573454965aa8837 (patch)
treece31689f14e083beaf3ba942d51726790a52d3cf
parent81bc00d61fd9872514e5e25b4af405e6d3c9202e (diff)
downloadspack-b60a0eea012587acef308d6df573454965aa8837.tar.gz
spack-b60a0eea012587acef308d6df573454965aa8837.tar.bz2
spack-b60a0eea012587acef308d6df573454965aa8837.tar.xz
spack-b60a0eea012587acef308d6df573454965aa8837.zip
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>
-rw-r--r--lib/spack/llnl/util/tty/__init__.py49
-rw-r--r--lib/spack/spack/build_environment.py2
-rw-r--r--lib/spack/spack/subprocess_context.py3
-rw-r--r--var/spack/repos/builtin/packages/wrf/package.py13
4 files changed, 43 insertions, 24 deletions
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py
index c60419be47..ad586e024d 100644
--- a/lib/spack/llnl/util/tty/__init__.py
+++ b/lib/spack/llnl/util/tty/__init__.py
@@ -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 @@ from datetime import datetime
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:
+ 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])
+ 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])
+ return int(rc[0]), int(rc[1])
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index be4e9f1d6d..a6757c9deb 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -1135,7 +1135,7 @@ def start_build_process(pkg, function, kwargs):
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)
diff --git a/lib/spack/spack/subprocess_context.py b/lib/spack/spack/subprocess_context.py
index af197b4a3c..4251516f82 100644
--- a/lib/spack/spack/subprocess_context.py
+++ b/lib/spack/spack/subprocess_context.py
@@ -27,7 +27,8 @@ import spack.platforms
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
diff --git a/var/spack/repos/builtin/packages/wrf/package.py b/var/spack/repos/builtin/packages/wrf/package.py
index cd433c1ac2..7beeee61b1 100644
--- a/var/spack/repos/builtin/packages/wrf/package.py
+++ b/var/spack/repos/builtin/packages/wrf/package.py
@@ -10,12 +10,19 @@ from fcntl import F_GETFL, F_SETFL, fcntl
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 @@ re_nestoptname = re.compile(r'=([^,)]+)')
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):