diff options
author | Betsy McPhail <betsy.mcphail@kitware.com> | 2021-10-21 16:30:16 -0400 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2022-03-17 09:01:01 -0700 |
commit | b60a0eea012587acef308d6df573454965aa8837 (patch) | |
tree | ce31689f14e083beaf3ba942d51726790a52d3cf /lib/spack | |
parent | 81bc00d61fd9872514e5e25b4af405e6d3c9202e (diff) | |
download | spack-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>
Diffstat (limited to 'lib/spack')
-rw-r--r-- | lib/spack/llnl/util/tty/__init__.py | 49 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/subprocess_context.py | 3 |
3 files changed, 32 insertions, 22 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 |