windows: use sys.platform == "win32" instead of is_windows (#35640)

`mypy` only understands `sys.platform == "win32"`, not indirect assignments of that
value to things like `is_windows`. If we don't use the accepted platform checks, `mypy`
registers many Windows-only symbols as not present on Linux, when it should skip the
checks for platform-specific code.
This commit is contained in:
Todd Gamblin 2023-03-05 07:58:05 -08:00 committed by GitHub
parent 4561536403
commit 42a02411b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 133 additions and 196 deletions

View File

@ -16,7 +16,6 @@
import sys import sys
import tempfile import tempfile
from contextlib import contextmanager from contextlib import contextmanager
from sys import platform as _platform
from typing import Callable, List, Match, Optional, Tuple, Union from typing import Callable, List, Match, Optional, Tuple, Union
from llnl.util import tty from llnl.util import tty
@ -26,9 +25,7 @@
from spack.util.executable import Executable, which from spack.util.executable import Executable, which
from spack.util.path import path_to_os_path, system_path_filter from spack.util.path import path_to_os_path, system_path_filter
is_windows = _platform == "win32" if sys.platform != "win32":
if not is_windows:
import grp import grp
import pwd import pwd
else: else:
@ -154,7 +151,7 @@ def lookup(name):
def getuid(): def getuid():
if is_windows: if sys.platform == "win32":
import ctypes import ctypes
if ctypes.windll.shell32.IsUserAnAdmin() == 0: if ctypes.windll.shell32.IsUserAnAdmin() == 0:
@ -167,7 +164,7 @@ def getuid():
@system_path_filter @system_path_filter
def rename(src, dst): def rename(src, dst):
# On Windows, os.rename will fail if the destination file already exists # On Windows, os.rename will fail if the destination file already exists
if is_windows: if sys.platform == "win32":
# Windows path existence checks will sometimes fail on junctions/links/symlinks # Windows path existence checks will sometimes fail on junctions/links/symlinks
# so check for that case # so check for that case
if os.path.exists(dst) or os.path.islink(dst): if os.path.exists(dst) or os.path.islink(dst):
@ -196,7 +193,7 @@ def _get_mime_type():
"""Generate method to call `file` system command to aquire mime type """Generate method to call `file` system command to aquire mime type
for a specified path for a specified path
""" """
if is_windows: if sys.platform == "win32":
# -h option (no-dereference) does not exist in Windows # -h option (no-dereference) does not exist in Windows
return file_command("-b", "--mime-type") return file_command("-b", "--mime-type")
else: else:
@ -551,7 +548,7 @@ def get_owner_uid(path, err_msg=None):
else: else:
p_stat = os.stat(path) p_stat = os.stat(path)
if _platform != "win32": if sys.platform != "win32":
owner_uid = p_stat.st_uid owner_uid = p_stat.st_uid
else: else:
sid = win32security.GetFileSecurity( sid = win32security.GetFileSecurity(
@ -584,7 +581,7 @@ def group_ids(uid=None):
Returns: Returns:
(list of int): gids of groups the user is a member of (list of int): gids of groups the user is a member of
""" """
if is_windows: if sys.platform == "win32":
tty.warn("Function is not supported on Windows") tty.warn("Function is not supported on Windows")
return [] return []
@ -604,7 +601,7 @@ def group_ids(uid=None):
@system_path_filter(arg_slice=slice(1)) @system_path_filter(arg_slice=slice(1))
def chgrp(path, group, follow_symlinks=True): def chgrp(path, group, follow_symlinks=True):
"""Implement the bash chgrp function on a single path""" """Implement the bash chgrp function on a single path"""
if is_windows: if sys.platform == "win32":
raise OSError("Function 'chgrp' is not supported on Windows") raise OSError("Function 'chgrp' is not supported on Windows")
if isinstance(group, str): if isinstance(group, str):
@ -1131,7 +1128,7 @@ def open_if_filename(str_or_file, mode="r"):
@system_path_filter @system_path_filter
def touch(path): def touch(path):
"""Creates an empty file at the specified path.""" """Creates an empty file at the specified path."""
if is_windows: if sys.platform == "win32":
perms = os.O_WRONLY | os.O_CREAT perms = os.O_WRONLY | os.O_CREAT
else: else:
perms = os.O_WRONLY | os.O_CREAT | os.O_NONBLOCK | os.O_NOCTTY perms = os.O_WRONLY | os.O_CREAT | os.O_NONBLOCK | os.O_NOCTTY
@ -1193,7 +1190,7 @@ def temp_cwd():
yield tmp_dir yield tmp_dir
finally: finally:
kwargs = {} kwargs = {}
if is_windows: if sys.platform == "win32":
kwargs["ignore_errors"] = False kwargs["ignore_errors"] = False
kwargs["onerror"] = readonly_file_handler(ignore_errors=True) kwargs["onerror"] = readonly_file_handler(ignore_errors=True)
shutil.rmtree(tmp_dir, **kwargs) shutil.rmtree(tmp_dir, **kwargs)
@ -1438,7 +1435,7 @@ def visit_directory_tree(root, visitor, rel_path="", depth=0):
try: try:
isdir = f.is_dir() isdir = f.is_dir()
except OSError as e: except OSError as e:
if is_windows and hasattr(e, "winerror") and e.winerror == 5 and islink: if sys.platform == "win32" and hasattr(e, "winerror") and e.winerror == 5 and islink:
# if path is a symlink, determine destination and # if path is a symlink, determine destination and
# evaluate file vs directory # evaluate file vs directory
link_target = resolve_link_target_relative_to_the_link(f) link_target = resolve_link_target_relative_to_the_link(f)
@ -1547,11 +1544,11 @@ def readonly_file_handler(ignore_errors=False):
""" """
def error_remove_readonly(func, path, exc): def error_remove_readonly(func, path, exc):
if not is_windows: if sys.platform != "win32":
raise RuntimeError("This method should only be invoked on Windows") raise RuntimeError("This method should only be invoked on Windows")
excvalue = exc[1] excvalue = exc[1]
if ( if (
is_windows sys.platform == "win32"
and func in (os.rmdir, os.remove, os.unlink) and func in (os.rmdir, os.remove, os.unlink)
and excvalue.errno == errno.EACCES and excvalue.errno == errno.EACCES
): ):
@ -1581,7 +1578,7 @@ def remove_linked_tree(path):
# Windows readonly files cannot be removed by Python # Windows readonly files cannot be removed by Python
# directly. # directly.
if is_windows: if sys.platform == "win32":
kwargs["ignore_errors"] = False kwargs["ignore_errors"] = False
kwargs["onerror"] = readonly_file_handler(ignore_errors=True) kwargs["onerror"] = readonly_file_handler(ignore_errors=True)
@ -2095,7 +2092,7 @@ def names(self):
# on non Windows platform # on non Windows platform
# Windows valid library extensions are: # Windows valid library extensions are:
# ['.dll', '.lib'] # ['.dll', '.lib']
valid_exts = [".dll", ".lib"] if is_windows else [".dylib", ".so", ".a"] valid_exts = [".dll", ".lib"] if sys.platform == "win32" else [".dylib", ".so", ".a"]
for ext in valid_exts: for ext in valid_exts:
i = name.rfind(ext) i = name.rfind(ext)
if i != -1: if i != -1:
@ -2243,7 +2240,7 @@ def find_libraries(libraries, root, shared=True, recursive=False, runtime=True):
message = message.format(find_libraries.__name__, type(libraries)) message = message.format(find_libraries.__name__, type(libraries))
raise TypeError(message) raise TypeError(message)
if is_windows: if sys.platform == "win32":
static_ext = "lib" static_ext = "lib"
# For linking (runtime=False) you need the .lib files regardless of # For linking (runtime=False) you need the .lib files regardless of
# whether you are doing a shared or static link # whether you are doing a shared or static link
@ -2275,7 +2272,7 @@ def find_libraries(libraries, root, shared=True, recursive=False, runtime=True):
# finally search all of root recursively. The search stops when the first # finally search all of root recursively. The search stops when the first
# match is found. # match is found.
common_lib_dirs = ["lib", "lib64"] common_lib_dirs = ["lib", "lib64"]
if is_windows: if sys.platform == "win32":
common_lib_dirs.extend(["bin", "Lib"]) common_lib_dirs.extend(["bin", "Lib"])
for subdir in common_lib_dirs: for subdir in common_lib_dirs:
@ -2410,7 +2407,7 @@ def _link(self, path, dest_dir):
# For py2 compatibility, we have to catch the specific Windows error code # For py2 compatibility, we have to catch the specific Windows error code
# associate with trying to create a file that already exists (winerror 183) # associate with trying to create a file that already exists (winerror 183)
except OSError as e: except OSError as e:
if e.winerror == 183: if sys.platform == "win32" and e.winerror == 183:
# We have either already symlinked or we are encoutering a naming clash # We have either already symlinked or we are encoutering a naming clash
# either way, we don't want to overwrite existing libraries # either way, we don't want to overwrite existing libraries
already_linked = islink(dest_file) already_linked = islink(dest_file)

View File

@ -5,15 +5,13 @@
import errno import errno
import os import os
import shutil import shutil
import sys
import tempfile import tempfile
from os.path import exists, join from os.path import exists, join
from sys import platform as _platform
from llnl.util import lang from llnl.util import lang
is_windows = _platform == "win32" if sys.platform == "win32":
if is_windows:
from win32file import CreateHardLink from win32file import CreateHardLink
@ -23,7 +21,7 @@ def symlink(real_path, link_path):
On Windows, use junctions if os.symlink fails. On Windows, use junctions if os.symlink fails.
""" """
if not is_windows: if sys.platform != "win32":
os.symlink(real_path, link_path) os.symlink(real_path, link_path)
elif _win32_can_symlink(): elif _win32_can_symlink():
# Windows requires target_is_directory=True when the target is a dir. # Windows requires target_is_directory=True when the target is a dir.
@ -99,7 +97,7 @@ def _win32_is_junction(path):
if os.path.islink(path): if os.path.islink(path):
return False return False
if is_windows: if sys.platform == "win32":
import ctypes.wintypes import ctypes.wintypes
GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW

View File

@ -26,7 +26,6 @@
description = "run spack's unit tests (wrapper around pytest)" description = "run spack's unit tests (wrapper around pytest)"
section = "developer" section = "developer"
level = "long" level = "long"
is_windows = sys.platform == "win32"
def setup_parser(subparser): def setup_parser(subparser):
@ -212,7 +211,7 @@ def unit_test(parser, args, unknown_args):
# mock configuration used by unit tests # mock configuration used by unit tests
# Note: skip on windows here because for the moment, # Note: skip on windows here because for the moment,
# clingo is wholly unsupported from bootstrap # clingo is wholly unsupported from bootstrap
if not is_windows: if sys.platform != "win32":
with spack.bootstrap.ensure_bootstrap_configuration(): with spack.bootstrap.ensure_bootstrap_configuration():
spack.bootstrap.ensure_core_dependencies() spack.bootstrap.ensure_core_dependencies()
if pytest is None: if pytest is None:

View File

@ -28,8 +28,6 @@
__all__ = ["Compiler"] __all__ = ["Compiler"]
is_windows = sys.platform == "win32"
@llnl.util.lang.memoized @llnl.util.lang.memoized
def _get_compiler_version_output(compiler_path, version_arg, ignore_errors=()): def _get_compiler_version_output(compiler_path, version_arg, ignore_errors=()):
@ -598,7 +596,7 @@ def search_regexps(cls, language):
suffixes = [""] suffixes = [""]
# Windows compilers generally have an extension of some sort # Windows compilers generally have an extension of some sort
# as do most files on Windows, handle that case here # as do most files on Windows, handle that case here
if is_windows: if sys.platform == "win32":
ext = r"\.(?:exe|bat)" ext = r"\.(?:exe|bat)"
cls_suf = [suf + ext for suf in cls.suffixes] cls_suf = [suf + ext for suf in cls.suffixes]
ext_suf = [ext] ext_suf = [ext]

View File

@ -29,7 +29,6 @@
import spack.util.spack_yaml import spack.util.spack_yaml
import spack.util.windows_registry import spack.util.windows_registry
is_windows = sys.platform == "win32"
#: Information on a package that has been detected #: Information on a package that has been detected
DetectedPackage = collections.namedtuple("DetectedPackage", ["spec", "prefix"]) DetectedPackage = collections.namedtuple("DetectedPackage", ["spec", "prefix"])
@ -184,7 +183,7 @@ def library_prefix(library_dir):
elif "lib" in lowered_components: elif "lib" in lowered_components:
idx = lowered_components.index("lib") idx = lowered_components.index("lib")
return os.sep.join(components[:idx]) return os.sep.join(components[:idx])
elif is_windows and "bin" in lowered_components: elif sys.platform == "win32" and "bin" in lowered_components:
idx = lowered_components.index("bin") idx = lowered_components.index("bin")
return os.sep.join(components[:idx]) return os.sep.join(components[:idx])
else: else:
@ -260,13 +259,13 @@ def find_windows_compiler_bundled_packages():
class WindowsKitExternalPaths(object): class WindowsKitExternalPaths(object):
if is_windows: if sys.platform == "win32":
plat_major_ver = str(winOs.windows_version()[0]) plat_major_ver = str(winOs.windows_version()[0])
@staticmethod @staticmethod
def find_windows_kit_roots(): def find_windows_kit_roots():
"""Return Windows kit root, typically %programfiles%\\Windows Kits\\10|11\\""" """Return Windows kit root, typically %programfiles%\\Windows Kits\\10|11\\"""
if not is_windows: if sys.platform != "win32":
return [] return []
program_files = os.environ["PROGRAMFILES(x86)"] program_files = os.environ["PROGRAMFILES(x86)"]
kit_base = os.path.join( kit_base = os.path.join(
@ -359,7 +358,7 @@ def compute_windows_program_path_for_package(pkg):
pkg (spack.package_base.PackageBase): package for which pkg (spack.package_base.PackageBase): package for which
Program Files location is to be computed Program Files location is to be computed
""" """
if not is_windows: if sys.platform != "win32":
return [] return []
# note windows paths are fine here as this method should only ever be invoked # note windows paths are fine here as this method should only ever be invoked
# to interact with Windows # to interact with Windows
@ -379,7 +378,7 @@ def compute_windows_user_path_for_package(pkg):
installs see: installs see:
https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.8 https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.8
""" """
if not is_windows: if sys.platform != "win32":
return [] return []
# Current user directory # Current user directory

View File

@ -31,8 +31,6 @@
path_to_dict, path_to_dict,
) )
is_windows = sys.platform == "win32"
def common_windows_package_paths(): def common_windows_package_paths():
paths = WindowsCompilerExternalPaths.find_windows_compiler_bundled_packages() paths = WindowsCompilerExternalPaths.find_windows_compiler_bundled_packages()
@ -57,7 +55,7 @@ def executables_in_path(path_hints):
path_hints (list): list of paths to be searched. If None the list will be path_hints (list): list of paths to be searched. If None the list will be
constructed based on the PATH environment variable. constructed based on the PATH environment variable.
""" """
if is_windows: if sys.platform == "win32":
path_hints.extend(common_windows_package_paths()) path_hints.extend(common_windows_package_paths())
search_paths = llnl.util.filesystem.search_paths_for_executables(*path_hints) search_paths = llnl.util.filesystem.search_paths_for_executables(*path_hints)
return path_to_dict(search_paths) return path_to_dict(search_paths)
@ -149,7 +147,7 @@ def by_library(packages_to_check, path_hints=None):
path_to_lib_name = ( path_to_lib_name = (
libraries_in_ld_and_system_library_path(path_hints=path_hints) libraries_in_ld_and_system_library_path(path_hints=path_hints)
if not is_windows if sys.platform != "win32"
else libraries_in_windows_paths(path_hints) else libraries_in_windows_paths(path_hints)
) )

View File

@ -21,7 +21,6 @@
import spack.util.spack_json as sjson import spack.util.spack_json as sjson
from spack.error import SpackError from spack.error import SpackError
is_windows = sys.platform == "win32"
# Note: Posixpath is used here as opposed to # Note: Posixpath is used here as opposed to
# os.path.join due to spack.spec.Spec.format # os.path.join due to spack.spec.Spec.format
# requiring forward slash path seperators at this stage # requiring forward slash path seperators at this stage
@ -346,7 +345,7 @@ def remove_install_directory(self, spec, deprecated=False):
# Windows readonly files cannot be removed by Python # Windows readonly files cannot be removed by Python
# directly, change permissions before attempting to remove # directly, change permissions before attempting to remove
if is_windows: if sys.platform == "win32":
kwargs = { kwargs = {
"ignore_errors": False, "ignore_errors": False,
"onerror": fs.readonly_file_handler(ignore_errors=False), "onerror": fs.readonly_file_handler(ignore_errors=False),

View File

@ -28,7 +28,6 @@
import os.path import os.path
import re import re
import shutil import shutil
import sys
import urllib.parse import urllib.parse
from typing import List, Optional from typing import List, Optional
@ -53,7 +52,6 @@
#: List of all fetch strategies, created by FetchStrategy metaclass. #: List of all fetch strategies, created by FetchStrategy metaclass.
all_strategies = [] all_strategies = []
is_windows = sys.platform == "win32"
CONTENT_TYPE_MISMATCH_WARNING_TEMPLATE = ( CONTENT_TYPE_MISMATCH_WARNING_TEMPLATE = (
"The contents of {subject} look like {content_type}. Either the URL" "The contents of {subject} look like {content_type}. Either the URL"

View File

@ -30,8 +30,7 @@
#: Groupdb does not exist on Windows, prevent imports #: Groupdb does not exist on Windows, prevent imports
#: on supported systems #: on supported systems
is_windows = sys.platform == "win32" if sys.platform != "win32":
if not is_windows:
import grp import grp
#: Spack itself also limits the shebang line to at most 4KB, which should be plenty. #: Spack itself also limits the shebang line to at most 4KB, which should be plenty.

View File

@ -84,9 +84,6 @@
#: queue invariants). #: queue invariants).
STATUS_REMOVED = "removed" STATUS_REMOVED = "removed"
is_windows = sys.platform == "win32"
is_osx = sys.platform == "darwin"
class InstallAction(object): class InstallAction(object):
#: Don't perform an install #: Don't perform an install
@ -169,9 +166,9 @@ def _do_fake_install(pkg):
if not pkg.name.startswith("lib"): if not pkg.name.startswith("lib"):
library = "lib" + library library = "lib" + library
plat_shared = ".dll" if is_windows else ".so" plat_shared = ".dll" if sys.platform == "win32" else ".so"
plat_static = ".lib" if is_windows else ".a" plat_static = ".lib" if sys.platform == "win32" else ".a"
dso_suffix = ".dylib" if is_osx else plat_shared dso_suffix = ".dylib" if sys.platform == "darwin" else plat_shared
# Install fake command # Install fake command
fs.mkdirp(pkg.prefix.bin) fs.mkdirp(pkg.prefix.bin)

View File

@ -92,9 +92,6 @@
_spack_configure_argsfile = "spack-configure-args.txt" _spack_configure_argsfile = "spack-configure-args.txt"
is_windows = sys.platform == "win32"
def deprecated_version(pkg, version): def deprecated_version(pkg, version):
"""Return True if the version is deprecated, False otherwise. """Return True if the version is deprecated, False otherwise.
@ -165,7 +162,7 @@ def windows_establish_runtime_linkage(self):
Performs symlinking to incorporate rpath dependencies to Windows runtime search paths Performs symlinking to incorporate rpath dependencies to Windows runtime search paths
""" """
if is_windows: if sys.platform == "win32":
self.win_rpath.add_library_dependent(*self.win_add_library_dependent()) self.win_rpath.add_library_dependent(*self.win_add_library_dependent())
self.win_rpath.add_rpath(*self.win_add_rpath()) self.win_rpath.add_rpath(*self.win_add_rpath())
self.win_rpath.establish_link() self.win_rpath.establish_link()
@ -210,7 +207,7 @@ def to_windows_exe(exe):
plat_exe = [] plat_exe = []
if hasattr(cls, "executables"): if hasattr(cls, "executables"):
for exe in cls.executables: for exe in cls.executables:
if is_windows: if sys.platform == "win32":
exe = to_windows_exe(exe) exe = to_windows_exe(exe)
plat_exe.append(exe) plat_exe.append(exe)
return plat_exe return plat_exe
@ -2401,7 +2398,7 @@ def rpath(self):
# on Windows, libraries of runtime interest are typically # on Windows, libraries of runtime interest are typically
# stored in the bin directory # stored in the bin directory
if is_windows: if sys.platform == "win32":
rpaths = [self.prefix.bin] rpaths = [self.prefix.bin]
rpaths.extend(d.prefix.bin for d in deps if os.path.isdir(d.prefix.bin)) rpaths.extend(d.prefix.bin for d in deps if os.path.isdir(d.prefix.bin))
else: else:

View File

@ -54,7 +54,6 @@
import itertools import itertools
import os import os
import re import re
import sys
import warnings import warnings
from typing import Tuple from typing import Tuple
@ -118,7 +117,6 @@
"SpecDeprecatedError", "SpecDeprecatedError",
] ]
is_windows = sys.platform == "win32"
#: Valid pattern for an identifier in Spack #: Valid pattern for an identifier in Spack
identifier_re = r"\w[\w-]*" identifier_re = r"\w[\w-]*"

View File

@ -16,8 +16,6 @@
from spack.main import SpackCommand from spack.main import SpackCommand
from spack.spec import Spec from spack.spec import Spec
is_windows = sys.platform == "win32"
@pytest.fixture @pytest.fixture
def executables_found(monkeypatch): def executables_found(monkeypatch):
@ -39,7 +37,7 @@ def _win_exe_ext():
def define_plat_exe(exe): def define_plat_exe(exe):
if is_windows: if sys.platform == "win32":
exe += ".bat" exe += ".bat"
return exe return exe

View File

@ -7,7 +7,6 @@
from spack.main import SpackCommand from spack.main import SpackCommand
is_windows = sys.platform == "win32"
resource = SpackCommand("resource") resource = SpackCommand("resource")
#: these are hashes used in mock packages #: these are hashes used in mock packages
@ -23,7 +22,7 @@
"bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c", "bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c",
"7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730", "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
] ]
if not is_windows if sys.platform != "win32"
else [ else [
"abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234",
"1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd", "1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd",
@ -68,7 +67,7 @@ def test_resource_list_only_hashes(mock_packages, capfd):
def test_resource_show(mock_packages, capfd): def test_resource_show(mock_packages, capfd):
test_hash = ( test_hash = (
"c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8" "c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8"
if not is_windows if sys.platform != "win32"
else "3c5b65abcd6a3b2c714dbf7c31ff65fe3748a1adc371f030c283007ca5534f11" else "3c5b65abcd6a3b2c714dbf7c31ff65fe3748a1adc371f030c283007ca5534f11"
) )
with capfd.disabled(): with capfd.disabled():

View File

@ -14,8 +14,6 @@
import spack.extensions import spack.extensions
import spack.main import spack.main
is_windows = sys.platform == "win32"
class Extension: class Extension:
"""Helper class to simplify the creation of simple command extension """Helper class to simplify the creation of simple command extension
@ -274,7 +272,7 @@ def test_variable_in_extension_path(config, working_env):
os.environ["_MY_VAR"] = os.path.join("my", "var") os.environ["_MY_VAR"] = os.path.join("my", "var")
ext_paths = [os.path.join("~", "${_MY_VAR}", "spack-extension-1")] ext_paths = [os.path.join("~", "${_MY_VAR}", "spack-extension-1")]
# Home env variable is USERPROFILE on Windows # Home env variable is USERPROFILE on Windows
home_env = "USERPROFILE" if is_windows else "HOME" home_env = "USERPROFILE" if sys.platform == "win32" else "HOME"
expected_ext_paths = [ expected_ext_paths = [
os.path.join(os.environ[home_env], os.environ["_MY_VAR"], "spack-extension-1") os.path.join(os.environ[home_env], os.environ["_MY_VAR"], "spack-extension-1")
] ]

View File

@ -25,8 +25,6 @@
from spack.spec import Spec from spack.spec import Spec
from spack.version import ver from spack.version import ver
is_windows = sys.platform == "win32"
def check_spec(abstract, concrete): def check_spec(abstract, concrete):
if abstract.versions.concrete: if abstract.versions.concrete:
@ -1138,7 +1136,7 @@ def test_custom_compiler_version(self):
def test_all_patches_applied(self): def test_all_patches_applied(self):
uuidpatch = ( uuidpatch = (
"a60a42b73e03f207433c5579de207c6ed61d58e4d12dd3b5142eb525728d89ea" "a60a42b73e03f207433c5579de207c6ed61d58e4d12dd3b5142eb525728d89ea"
if not is_windows if sys.platform != "win32"
else "d0df7988457ec999c148a4a2af25ce831bfaad13954ba18a4446374cb0aef55e" else "d0df7988457ec999c148a4a2af25ce831bfaad13954ba18a4446374cb0aef55e"
) )
localpatch = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" localpatch = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

View File

@ -54,8 +54,6 @@
from spack.util.pattern import Bunch from spack.util.pattern import Bunch
from spack.util.web import FetchError from spack.util.web import FetchError
is_windows = sys.platform == "win32"
def ensure_configuration_fixture_run_before(request): def ensure_configuration_fixture_run_before(request):
"""Ensure that fixture mutating the configuration run before the one where """Ensure that fixture mutating the configuration run before the one where
@ -621,7 +619,7 @@ def ensure_debug(monkeypatch):
tty.set_debug(current_debug_level) tty.set_debug(current_debug_level)
@pytest.fixture(autouse=is_windows, scope="session") @pytest.fixture(autouse=sys.platform == "win32", scope="session")
def platform_config(): def platform_config():
spack.config.add_default_platform_scope(spack.platforms.real_host().name) spack.config.add_default_platform_scope(spack.platforms.real_host().name)
@ -633,7 +631,7 @@ def default_config():
This ensures we can test the real default configuration without having This ensures we can test the real default configuration without having
tests fail when the user overrides the defaults that we test against.""" tests fail when the user overrides the defaults that we test against."""
defaults_path = os.path.join(spack.paths.etc_path, "defaults") defaults_path = os.path.join(spack.paths.etc_path, "defaults")
if is_windows: if sys.platform == "win32":
defaults_path = os.path.join(defaults_path, "windows") defaults_path = os.path.join(defaults_path, "windows")
with spack.config.use_configuration(defaults_path) as defaults_config: with spack.config.use_configuration(defaults_path) as defaults_config:
yield defaults_config yield defaults_config
@ -690,7 +688,7 @@ def configuration_dir(tmpdir_factory, linux_os):
tmpdir.ensure("user", dir=True) tmpdir.ensure("user", dir=True)
# Slightly modify config.yaml and compilers.yaml # Slightly modify config.yaml and compilers.yaml
if is_windows: if sys.platform == "win32":
locks = False locks = False
else: else:
locks = True locks = True
@ -1675,11 +1673,11 @@ def mock_executable(tmpdir):
""" """
import jinja2 import jinja2
shebang = "#!/bin/sh\n" if not is_windows else "@ECHO OFF" shebang = "#!/bin/sh\n" if sys.platform != "win32" else "@ECHO OFF"
def _factory(name, output, subdir=("bin",)): def _factory(name, output, subdir=("bin",)):
f = tmpdir.ensure(*subdir, dir=True).join(name) f = tmpdir.ensure(*subdir, dir=True).join(name)
if is_windows: if sys.platform == "win32":
f += ".bat" f += ".bat"
t = jinja2.Template("{{ shebang }}{{ output }}\n") t = jinja2.Template("{{ shebang }}{{ output }}\n")
f.write(t.render(shebang=shebang, output=output)) f.write(t.render(shebang=shebang, output=output))

View File

@ -33,8 +33,6 @@
from spack.schema.database_index import schema from spack.schema.database_index import schema
from spack.util.executable import Executable from spack.util.executable import Executable
is_windows = sys.platform == "win32"
pytestmark = pytest.mark.db pytestmark = pytest.mark.db
@ -451,7 +449,7 @@ def test_005_db_exists(database):
lock_file = os.path.join(database.root, ".spack-db", "lock") lock_file = os.path.join(database.root, ".spack-db", "lock")
assert os.path.exists(str(index_file)) assert os.path.exists(str(index_file))
# Lockfiles not currently supported on Windows # Lockfiles not currently supported on Windows
if not is_windows: if sys.platform != "win32":
assert os.path.exists(str(lock_file)) assert os.path.exists(str(lock_file))
with open(index_file) as fd: with open(index_file) as fd:

View File

@ -24,8 +24,6 @@
import spack.store import spack.store
import spack.util.lock as lk import spack.util.lock as lk
is_windows = sys.platform == "win32"
def _mock_repo(root, namespace): def _mock_repo(root, namespace):
"""Create an empty repository at the specified root """Create an empty repository at the specified root
@ -528,7 +526,7 @@ def _repoerr(repo, name):
# The call to install_tree will raise the exception since not mocking # The call to install_tree will raise the exception since not mocking
# creation of dependency package files within *install* directories. # creation of dependency package files within *install* directories.
with pytest.raises(IOError, match=path if not is_windows else ""): with pytest.raises(IOError, match=path if sys.platform != "win32" else ""):
inst.dump_packages(spec, path) inst.dump_packages(spec, path)
# Now try the error path, which requires the mock directory structure # Now try the error path, which requires the mock directory structure
@ -879,7 +877,7 @@ def _chgrp(path, group, follow_symlinks=True):
metadatadir = spack.store.layout.metadata_path(spec) metadatadir = spack.store.layout.metadata_path(spec)
# Regex matching with Windows style paths typically fails # Regex matching with Windows style paths typically fails
# so we skip the match check here # so we skip the match check here
if is_windows: if sys.platform == "win32":
metadatadir = None metadatadir = None
# Should fail with a "not a directory" error # Should fail with a "not a directory" error
with pytest.raises(OSError, match=metadatadir): with pytest.raises(OSError, match=metadatadir):

View File

@ -11,9 +11,8 @@
import spack.paths import spack.paths
from spack.compiler import _parse_non_system_link_dirs from spack.compiler import _parse_non_system_link_dirs
is_windows = sys.platform == "win32"
drive = "" drive = ""
if is_windows: if sys.platform == "win32":
match = re.search(r"[A-Za-z]:", spack.paths.test_path) match = re.search(r"[A-Za-z]:", spack.paths.test_path)
if match: if match:
drive = match.group() drive = match.group()
@ -210,7 +209,7 @@ def test_obscure_parsing_rules():
] ]
# TODO: add a comment explaining why this happens # TODO: add a comment explaining why this happens
if is_windows: if sys.platform == "win32":
paths.remove(os.path.join(root, "second", "path")) paths.remove(os.path.join(root, "second", "path"))
check_link_paths("obscure-parsing-rules.txt", paths) check_link_paths("obscure-parsing-rules.txt", paths)

View File

@ -13,8 +13,6 @@
import spack.paths import spack.paths
is_windows = sys.platform == "win32"
@pytest.fixture() @pytest.fixture()
def library_list(): def library_list():
@ -28,7 +26,7 @@ def library_list():
"/dir3/libz.so", "/dir3/libz.so",
"libmpi.so.20.10.1", # shared object libraries may be versioned "libmpi.so.20.10.1", # shared object libraries may be versioned
] ]
if not is_windows if sys.platform != "win32"
else [ else [
"/dir1/liblapack.lib", "/dir1/liblapack.lib",
"/dir2/libpython3.6.dll", "/dir2/libpython3.6.dll",
@ -59,10 +57,10 @@ def header_list():
# TODO: Remove below when llnl.util.filesystem.find_libraries becomes spec aware # TODO: Remove below when llnl.util.filesystem.find_libraries becomes spec aware
plat_static_ext = "lib" if is_windows else "a" plat_static_ext = "lib" if sys.platform == "win32" else "a"
plat_shared_ext = "dll" if is_windows else "so" plat_shared_ext = "dll" if sys.platform == "win32" else "so"
plat_apple_shared_ext = "dylib" plat_apple_shared_ext = "dylib"
@ -78,7 +76,8 @@ def test_joined_and_str(self, library_list):
expected = " ".join( expected = " ".join(
[ [
"/dir1/liblapack.%s" % plat_static_ext, "/dir1/liblapack.%s" % plat_static_ext,
"/dir2/libpython3.6.%s" % (plat_apple_shared_ext if not is_windows else "dll"), "/dir2/libpython3.6.%s"
% (plat_apple_shared_ext if sys.platform != "win32" else "dll"),
"/dir1/libblas.%s" % plat_static_ext, "/dir1/libblas.%s" % plat_static_ext,
"/dir3/libz.%s" % plat_shared_ext, "/dir3/libz.%s" % plat_shared_ext,
"libmpi.%s.20.10.1" % plat_shared_ext, "libmpi.%s.20.10.1" % plat_shared_ext,
@ -93,7 +92,8 @@ def test_joined_and_str(self, library_list):
expected = ";".join( expected = ";".join(
[ [
"/dir1/liblapack.%s" % plat_static_ext, "/dir1/liblapack.%s" % plat_static_ext,
"/dir2/libpython3.6.%s" % (plat_apple_shared_ext if not is_windows else "dll"), "/dir2/libpython3.6.%s"
% (plat_apple_shared_ext if sys.platform != "win32" else "dll"),
"/dir1/libblas.%s" % plat_static_ext, "/dir1/libblas.%s" % plat_static_ext,
"/dir3/libz.%s" % plat_shared_ext, "/dir3/libz.%s" % plat_shared_ext,
"libmpi.%s.20.10.1" % plat_shared_ext, "libmpi.%s.20.10.1" % plat_shared_ext,

View File

@ -62,8 +62,7 @@
import llnl.util.multiproc as mp import llnl.util.multiproc as mp
from llnl.util.filesystem import getuid, touch from llnl.util.filesystem import getuid, touch
is_windows = sys.platform == "win32" if sys.platform != "win32":
if not is_windows:
import fcntl import fcntl
pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows") pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
@ -127,7 +126,7 @@ def make_readable(*paths):
# stat.S_IREAD constants or a corresponding integer value). All other # stat.S_IREAD constants or a corresponding integer value). All other
# bits are ignored." # bits are ignored."
for path in paths: for path in paths:
if not is_windows: if sys.platform != "win32":
mode = 0o555 if os.path.isdir(path) else 0o444 mode = 0o555 if os.path.isdir(path) else 0o444
else: else:
mode = stat.S_IREAD mode = stat.S_IREAD
@ -136,7 +135,7 @@ def make_readable(*paths):
def make_writable(*paths): def make_writable(*paths):
for path in paths: for path in paths:
if not is_windows: if sys.platform != "win32":
mode = 0o755 if os.path.isdir(path) else 0o744 mode = 0o755 if os.path.isdir(path) else 0o744
else: else:
mode = stat.S_IWRITE mode = stat.S_IWRITE
@ -616,7 +615,7 @@ def test_read_lock_read_only_dir_writable_lockfile(lock_dir, lock_path):
pass pass
@pytest.mark.skipif(False if is_windows else getuid() == 0, reason="user is root") @pytest.mark.skipif(False if sys.platform == "win32" else getuid() == 0, reason="user is root")
def test_read_lock_no_lockfile(lock_dir, lock_path): def test_read_lock_no_lockfile(lock_dir, lock_path):
"""read-only directory, no lockfile (so can't create).""" """read-only directory, no lockfile (so can't create)."""
with read_only(lock_dir): with read_only(lock_dir):

View File

@ -20,7 +20,6 @@
from spack.spec import Spec from spack.spec import Spec
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import Executable from spack.util.executable import Executable
from spack.util.path import is_windows
# various sha256 sums (using variables for legibility) # various sha256 sums (using variables for legibility)
# many file based shas will differ between Windows and other platforms # many file based shas will differ between Windows and other platforms
@ -29,22 +28,22 @@
# files with contents 'foo', 'bar', and 'baz' # files with contents 'foo', 'bar', and 'baz'
foo_sha256 = ( foo_sha256 = (
"b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c" "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"
if not is_windows if sys.platform != "win32"
else "bf874c7dd3a83cf370fdc17e496e341de06cd596b5c66dbf3c9bb7f6c139e3ee" else "bf874c7dd3a83cf370fdc17e496e341de06cd596b5c66dbf3c9bb7f6c139e3ee"
) )
bar_sha256 = ( bar_sha256 = (
"7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730" "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730"
if not is_windows if sys.platform != "win32"
else "556ddc69a75d0be0ecafc82cd4657666c8063f13d762282059c39ff5dbf18116" else "556ddc69a75d0be0ecafc82cd4657666c8063f13d762282059c39ff5dbf18116"
) )
baz_sha256 = ( baz_sha256 = (
"bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c" "bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c"
if not is_windows if sys.platform != "win32"
else "d30392e66c636a063769cbb1db08cd3455a424650d4494db6379d73ea799582b" else "d30392e66c636a063769cbb1db08cd3455a424650d4494db6379d73ea799582b"
) )
biz_sha256 = ( biz_sha256 = (
"a69b288d7393261e613c276c6d38a01461028291f6e381623acc58139d01f54d" "a69b288d7393261e613c276c6d38a01461028291f6e381623acc58139d01f54d"
if not is_windows if sys.platform != "win32"
else "2f2b087a8f84834fd03d4d1d5b43584011e869e4657504ef3f8b0a672a5c222e" else "2f2b087a8f84834fd03d4d1d5b43584011e869e4657504ef3f8b0a672a5c222e"
) )
@ -56,7 +55,7 @@
platform_url_sha = ( platform_url_sha = (
"252c0af58be3d90e5dc5e0d16658434c9efa5d20a5df6c10bf72c2d77f780866" "252c0af58be3d90e5dc5e0d16658434c9efa5d20a5df6c10bf72c2d77f780866"
if not is_windows if sys.platform != "win32"
else "ecf44a8244a486e9ef5f72c6cb622f99718dcd790707ac91af0b8c9a4ab7a2bb" else "ecf44a8244a486e9ef5f72c6cb622f99718dcd790707ac91af0b8c9a4ab7a2bb"
) )
@ -160,17 +159,17 @@ def test_patch_order(mock_packages, config):
mid2_sha256 = ( mid2_sha256 = (
"mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" "mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
if not is_windows if sys.platform != "win32"
else "mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" else "mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
) )
mid1_sha256 = ( mid1_sha256 = (
"0b62284961dab49887e31319843431ee5b037382ac02c4fe436955abef11f094" "0b62284961dab49887e31319843431ee5b037382ac02c4fe436955abef11f094"
if not is_windows if sys.platform != "win32"
else "aeb16c4dec1087e39f2330542d59d9b456dd26d791338ae6d80b6ffd10c89dfa" else "aeb16c4dec1087e39f2330542d59d9b456dd26d791338ae6d80b6ffd10c89dfa"
) )
top_sha256 = ( top_sha256 = (
"f7de2947c64cb6435e15fb2bef359d1ed5f6356b2aebb7b20535e3772904e6db" "f7de2947c64cb6435e15fb2bef359d1ed5f6356b2aebb7b20535e3772904e6db"
if not is_windows if sys.platform != "win32"
else "ff34cb21271d16dbf928374f610bb5dd593d293d311036ddae86c4846ff79070" else "ff34cb21271d16dbf928374f610bb5dd593d293d311036ddae86c4846ff79070"
) )
@ -219,7 +218,7 @@ def test_patched_dependency(mock_packages, config, install_mockery, mock_fetch):
# make sure the patch makes it into the dependency spec # make sure the patch makes it into the dependency spec
t_sha = ( t_sha = (
"c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8" "c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8"
if not is_windows if sys.platform != "win32"
else "3c5b65abcd6a3b2c714dbf7c31ff65fe3748a1adc371f030c283007ca5534f11" else "3c5b65abcd6a3b2c714dbf7c31ff65fe3748a1adc371f030c283007ca5534f11"
) )
assert (t_sha,) == spec["libelf"].variants["patches"].value assert (t_sha,) == spec["libelf"].variants["patches"].value

View File

@ -11,8 +11,6 @@
import spack.util.environment as envutil import spack.util.environment as envutil
is_windows = sys.platform == "win32"
@pytest.fixture() @pytest.fixture()
def prepare_environment_for_tests(): def prepare_environment_for_tests():
@ -23,14 +21,14 @@ def prepare_environment_for_tests():
def test_is_system_path(): def test_is_system_path():
sys_path = "C:\\Users" if is_windows else "/usr/bin" sys_path = "C:\\Users" if sys.platform == "win32" else "/usr/bin"
assert envutil.is_system_path(sys_path) assert envutil.is_system_path(sys_path)
assert not envutil.is_system_path("/nonsense_path/bin") assert not envutil.is_system_path("/nonsense_path/bin")
assert not envutil.is_system_path("") assert not envutil.is_system_path("")
assert not envutil.is_system_path(None) assert not envutil.is_system_path(None)
if is_windows: if sys.platform == "win32":
test_paths = [ test_paths = [
"C:\\Users", "C:\\Users",
"C:\\", "C:\\",
@ -51,7 +49,7 @@ def test_is_system_path():
def test_filter_system_paths(): def test_filter_system_paths():
nonsense_prefix = "C:\\nonsense_path" if is_windows else "/nonsense_path" nonsense_prefix = "C:\\nonsense_path" if sys.platform == "win32" else "/nonsense_path"
expected = [p for p in test_paths if p.startswith(nonsense_prefix)] expected = [p for p in test_paths if p.startswith(nonsense_prefix)]
filtered = envutil.filter_system_paths(test_paths) filtered = envutil.filter_system_paths(test_paths)
assert expected == filtered assert expected == filtered

View File

@ -14,13 +14,11 @@
import spack.util.executable as ex import spack.util.executable as ex
from spack.hooks.sbang import filter_shebangs_in_directory from spack.hooks.sbang import filter_shebangs_in_directory
is_windows = sys.platform == "win32"
def test_read_unicode(tmpdir, working_env): def test_read_unicode(tmpdir, working_env):
script_name = "print_unicode.py" script_name = "print_unicode.py"
# read the unicode back in and see whether things work # read the unicode back in and see whether things work
if is_windows: if sys.platform == "win32":
script = ex.Executable("%s %s" % (sys.executable, script_name)) script = ex.Executable("%s %s" % (sys.executable, script_name))
else: else:
script = ex.Executable("./%s" % script_name) script = ex.Executable("./%s" % script_name)

View File

@ -13,9 +13,6 @@
import spack.config import spack.config
import spack.util.path as sup import spack.util.path as sup
is_windows = sys.platform == "win32"
#: Some lines with lots of placeholders #: Some lines with lots of placeholders
padded_lines = [ padded_lines = [
"==> [2021-06-23-15:59:05.020387] './configure' '--prefix=/Users/gamblin2/padding-log-test/opt/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_pla/darwin-bigsur-skylake/apple-clang-12.0.5/zlib-1.2.11-74mwnxgn6nujehpyyalhwizwojwn5zga", # noqa: E501 "==> [2021-06-23-15:59:05.020387] './configure' '--prefix=/Users/gamblin2/padding-log-test/opt/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_pla/darwin-bigsur-skylake/apple-clang-12.0.5/zlib-1.2.11-74mwnxgn6nujehpyyalhwizwojwn5zga", # noqa: E501
@ -36,7 +33,7 @@ def test_sanitze_file_path(tmpdir):
"""Test filtering illegal characters out of potential file paths""" """Test filtering illegal characters out of potential file paths"""
# *nix illegal files characters are '/' and none others # *nix illegal files characters are '/' and none others
illegal_file_path = str(tmpdir) + "//" + "abcdefghi.txt" illegal_file_path = str(tmpdir) + "//" + "abcdefghi.txt"
if is_windows: if sys.platform == "win32":
# Windows has a larger set of illegal characters # Windows has a larger set of illegal characters
illegal_file_path = os.path.join(tmpdir, 'a<b>cd?e:f"g|h*i.txt') illegal_file_path = os.path.join(tmpdir, 'a<b>cd?e:f"g|h*i.txt')
real_path = sup.sanitize_file_path(illegal_file_path) real_path = sup.sanitize_file_path(illegal_file_path)
@ -46,7 +43,7 @@ def test_sanitze_file_path(tmpdir):
# This class pertains to path string padding manipulation specifically # This class pertains to path string padding manipulation specifically
# which is used for binary caching. This functionality is not supported # which is used for binary caching. This functionality is not supported
# on Windows as of yet. # on Windows as of yet.
@pytest.mark.skipif(is_windows, reason="Padding funtionality unsupported on Windows") @pytest.mark.skipif(sys.platform == "win32", reason="Padding funtionality unsupported on Windows")
class TestPathPadding: class TestPathPadding:
@pytest.mark.parametrize("padded,fixed", zip(padded_lines, fixed_lines)) @pytest.mark.parametrize("padded,fixed", zip(padded_lines, fixed_lines))
def test_padding_substitution(self, padded, fixed): def test_padding_substitution(self, padded, fixed):
@ -122,7 +119,7 @@ def test_path_debug_padded_filter(debug, monkeypatch):
string = fmt.format(prefix, os.sep, os.sep.join([sup.SPACK_PATH_PADDING_CHARS] * 2), suffix) string = fmt.format(prefix, os.sep, os.sep.join([sup.SPACK_PATH_PADDING_CHARS] * 2), suffix)
expected = ( expected = (
fmt.format(prefix, os.sep, "[padded-to-{0}-chars]".format(72), suffix) fmt.format(prefix, os.sep, "[padded-to-{0}-chars]".format(72), suffix)
if debug <= 1 and not is_windows if debug <= 1 and sys.platform != "win32"
else string else string
) )

View File

@ -28,8 +28,6 @@
ALLOWED_SINGLE_EXT_ARCHIVE_TYPES = PRE_EXTS + EXTS + NOTAR_EXTS ALLOWED_SINGLE_EXT_ARCHIVE_TYPES = PRE_EXTS + EXTS + NOTAR_EXTS
is_windows = sys.platform == "win32"
try: try:
import bz2 # noqa import bz2 # noqa
@ -158,7 +156,7 @@ def _unzip(archive_file):
archive_file (str): absolute path of the file to be decompressed archive_file (str): absolute path of the file to be decompressed
""" """
extracted_file = os.path.basename(strip_extension(archive_file, "zip")) extracted_file = os.path.basename(strip_extension(archive_file, "zip"))
if is_windows: if sys.platform == "win32":
return _untar(archive_file) return _untar(archive_file)
else: else:
exe = "unzip" exe = "unzip"
@ -170,7 +168,7 @@ def _unzip(archive_file):
def _unZ(archive_file): def _unZ(archive_file):
if is_windows: if sys.platform == "win32":
result = _7zip(archive_file) result = _7zip(archive_file)
else: else:
result = _system_gunzip(archive_file) result = _system_gunzip(archive_file)
@ -189,7 +187,7 @@ def _lzma_decomp(archive_file):
with lzma.open(archive_file) as lar: with lzma.open(archive_file) as lar:
shutil.copyfileobj(lar, ar) shutil.copyfileobj(lar, ar)
else: else:
if is_windows: if sys.platform == "win32":
return _7zip(archive_file) return _7zip(archive_file)
else: else:
return _xz(archive_file) return _xz(archive_file)
@ -227,7 +225,7 @@ def _xz(archive_file):
"""Decompress lzma compressed .xz files via xz command line """Decompress lzma compressed .xz files via xz command line
tool. Available only on Unix tool. Available only on Unix
""" """
if is_windows: if sys.platform == "win32":
raise RuntimeError("XZ tool unavailable on Windows") raise RuntimeError("XZ tool unavailable on Windows")
decompressed_file = os.path.basename(strip_extension(archive_file, "xz")) decompressed_file = os.path.basename(strip_extension(archive_file, "xz"))
working_dir = os.getcwd() working_dir = os.getcwd()
@ -310,7 +308,7 @@ def decompressor_for(path, extension=None):
# Catch tar.xz/tar.Z files here for Windows # Catch tar.xz/tar.Z files here for Windows
# as the tar utility on Windows cannot handle such # as the tar utility on Windows cannot handle such
# compression types directly # compression types directly
if ("xz" in extension or "Z" in extension) and is_windows: if ("xz" in extension or "Z" in extension) and sys.platform == "win32":
return _win_compressed_tarball_handler return _win_compressed_tarball_handler
return _untar return _untar

View File

@ -21,8 +21,6 @@
import spack.error import spack.error
import spack.paths import spack.paths
is_windows = sys.platform == "win32"
class Lock(llnl.util.lock.Lock): class Lock(llnl.util.lock.Lock):
"""Lock that can be disabled. """Lock that can be disabled.
@ -34,7 +32,7 @@ class Lock(llnl.util.lock.Lock):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(Lock, self).__init__(*args, **kwargs) super(Lock, self).__init__(*args, **kwargs)
self._enable = spack.config.get("config:locks", not is_windows) self._enable = spack.config.get("config:locks", sys.platform != "win32")
def _lock(self, op, timeout=0): def _lock(self, op, timeout=0):
if self._enable: if self._enable:

View File

@ -22,8 +22,6 @@
import spack.util.spack_yaml as syaml import spack.util.spack_yaml as syaml
is_windows = sys.platform == "win32"
__all__ = ["substitute_config_variables", "substitute_path_variables", "canonicalize_path"] __all__ = ["substitute_config_variables", "substitute_path_variables", "canonicalize_path"]
@ -153,7 +151,7 @@ def sanitize_file_path(pth):
# instances of illegal characters on join # instances of illegal characters on join
pth_cmpnts = pth.split(os.path.sep) pth_cmpnts = pth.split(os.path.sep)
if is_windows: if sys.platform == "win32":
drive_match = r"[a-zA-Z]:" drive_match = r"[a-zA-Z]:"
is_abs = bool(re.match(drive_match, pth_cmpnts[0])) is_abs = bool(re.match(drive_match, pth_cmpnts[0]))
drive = pth_cmpnts[0] + os.path.sep if is_abs else "" drive = pth_cmpnts[0] + os.path.sep if is_abs else ""
@ -210,7 +208,7 @@ def path_filter_caller(*args, **kwargs):
def get_system_path_max(): def get_system_path_max():
# Choose a conservative default # Choose a conservative default
sys_max_path_length = 256 sys_max_path_length = 256
if is_windows: if sys.platform == "win32":
sys_max_path_length = 260 sys_max_path_length = 260
else: else:
try: try:
@ -238,7 +236,7 @@ class Path:
unix = 0 unix = 0
windows = 1 windows = 1
platform_path = windows if is_windows else unix platform_path = windows if sys.platform == "win32" else unix
def format_os_path(path, mode=Path.unix): def format_os_path(path, mode=Path.unix):
@ -487,7 +485,7 @@ def debug_padded_filter(string, level=1):
Returns (str): filtered string if current debug level does not exceed Returns (str): filtered string if current debug level does not exceed
level and not windows; otherwise, unfiltered string level and not windows; otherwise, unfiltered string
""" """
if is_windows: if sys.platform == "win32":
return string return string
return padding_filter(string) if tty.debug_level() <= level else string return padding_filter(string) if tty.debug_level() <= level else string

View File

@ -13,8 +13,7 @@
from llnl.util import tty from llnl.util import tty
is_windows = sys.platform == "win32" if sys.platform == "win32":
if is_windows:
import winreg import winreg
@ -154,7 +153,7 @@ def __init__(self, key, root_key=HKEY.HKEY_CURRENT_USER):
to get an entrypoint, the HKEY constants are always open, or an already to get an entrypoint, the HKEY constants are always open, or an already
open key can be used instead. open key can be used instead.
""" """
if not is_windows: if sys.platform != "win32":
raise RuntimeError( raise RuntimeError(
"Cannot instantiate Windows Registry class on non Windows platforms" "Cannot instantiate Windows Registry class on non Windows platforms"
) )
@ -167,7 +166,7 @@ def invalid_reg_ref_error_handler(self):
try: try:
yield yield
except FileNotFoundError as e: except FileNotFoundError as e:
if e.winerror == 2: if sys.platform == "win32" and e.winerror == 2:
tty.debug("Key %s at position %s does not exist" % (self.key, str(self.root))) tty.debug("Key %s at position %s does not exist" % (self.key, str(self.root)))
else: else:
raise e raise e
@ -182,7 +181,7 @@ def _load_key(self):
winreg.OpenKeyEx(self.root.hkey, self.key, access=winreg.KEY_READ), winreg.OpenKeyEx(self.root.hkey, self.key, access=winreg.KEY_READ),
) )
except FileNotFoundError as e: except FileNotFoundError as e:
if e.winerror == 2: if sys.platform == "win32" and e.winerror == 2:
self._reg = -1 self._reg = -1
tty.debug("Key %s at position %s does not exist" % (self.key, str(self.root))) tty.debug("Key %s at position %s does not exist" % (self.key, str(self.root)))
else: else:

View File

@ -8,8 +8,6 @@
from spack.package import * from spack.package import *
is_windows = sys.platform == "win32"
def check(condition, msg): def check(condition, msg):
"""Raise an install error if condition is False.""" """Raise an install error if condition is False."""
@ -59,7 +57,7 @@ def install(self, spec, prefix):
os.environ["for_install"] == "for_install", os.environ["for_install"] == "for_install",
"Couldn't read env var set in compile envieonmnt", "Couldn't read env var set in compile envieonmnt",
) )
cmake_exe_ext = ".exe" if is_windows else "" cmake_exe_ext = ".exe" if sys.platform == "win32" else ""
cmake_exe = join_path(prefix.bin, "cmake{}".format(cmake_exe_ext)) cmake_exe = join_path(prefix.bin, "cmake{}".format(cmake_exe_ext))
touch(cmake_exe) touch(cmake_exe)
set_executable(cmake_exe) set_executable(cmake_exe)

View File

@ -10,8 +10,6 @@
import spack.build_environment import spack.build_environment
from spack.package import * from spack.package import *
is_windows = sys.platform == "win32"
class Cmake(Package): class Cmake(Package):
"""A cross-platform, open-source build system. CMake is a family of """A cross-platform, open-source build system. CMake is a family of
@ -187,7 +185,11 @@ class Cmake(Package):
default=False, default=False,
description="Enables the generation of html and man page documentation", description="Enables the generation of html and man page documentation",
) )
variant("ncurses", default=not is_windows, description="Enables the build of the ncurses gui") variant(
"ncurses",
default=sys.platform != "win32",
description="Enables the build of the ncurses gui",
)
# See https://gitlab.kitware.com/cmake/cmake/-/issues/21135 # See https://gitlab.kitware.com/cmake/cmake/-/issues/21135
conflicts( conflicts(

View File

@ -23,8 +23,6 @@
from spack.operating_systems.mac_os import macos_version from spack.operating_systems.mac_os import macos_version
from spack.package import * from spack.package import *
is_windows = sys.platform == "win32"
class Perl(Package): # Perl doesn't use Autotools, it should subclass Package class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
"""Perl 5 is a highly capable, feature-rich programming language with over """Perl 5 is a highly capable, feature-rich programming language with over
@ -76,7 +74,7 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
extendable = True extendable = True
if not is_windows: if sys.platform != "win32":
depends_on("gdbm@:1.23") depends_on("gdbm@:1.23")
# Bind us below gdbm-1.20 due to API change: https://github.com/Perl/perl5/issues/18915 # Bind us below gdbm-1.20 due to API change: https://github.com/Perl/perl5/issues/18915
depends_on("gdbm@:1.19", when="@:5.35") depends_on("gdbm@:1.19", when="@:5.35")
@ -277,13 +275,13 @@ def configure_args(self):
return config_args return config_args
def configure(self, spec, prefix): def configure(self, spec, prefix):
if is_windows: if sys.platform == "win32":
return return
configure = Executable("./Configure") configure = Executable("./Configure")
configure(*self.configure_args()) configure(*self.configure_args())
def build(self, spec, prefix): def build(self, spec, prefix):
if is_windows: if sys.platform == "win32":
pass pass
else: else:
make() make()
@ -291,7 +289,7 @@ def build(self, spec, prefix):
@run_after("build") @run_after("build")
@on_package_attributes(run_tests=True) @on_package_attributes(run_tests=True)
def build_test(self): def build_test(self):
if is_windows: if sys.platform == "win32":
win32_dir = os.path.join(self.stage.source_path, "win32") win32_dir = os.path.join(self.stage.source_path, "win32")
with working_dir(win32_dir): with working_dir(win32_dir):
nmake("test", ignore_quotes=True) nmake("test", ignore_quotes=True)
@ -299,7 +297,7 @@ def build_test(self):
make("test") make("test")
def install(self, spec, prefix): def install(self, spec, prefix):
if is_windows: if sys.platform == "win32":
win32_dir = os.path.join(self.stage.source_path, "win32") win32_dir = os.path.join(self.stage.source_path, "win32")
with working_dir(win32_dir): with working_dir(win32_dir):
nmake("install", *self.nmake_arguments, ignore_quotes=True) nmake("install", *self.nmake_arguments, ignore_quotes=True)
@ -308,7 +306,7 @@ def install(self, spec, prefix):
@run_after("install") @run_after("install")
def symlink_windows(self): def symlink_windows(self):
if not is_windows: if sys.platform != "win32":
return return
win_install_path = os.path.join(self.prefix.bin, "MSWin32") win_install_path = os.path.join(self.prefix.bin, "MSWin32")
if self.is_64bit(): if self.is_64bit():
@ -331,7 +329,7 @@ def install_cpanm(self):
spec = self.spec spec = self.spec
maker = make maker = make
cpan_dir = join_path("cpanm", "cpanm") cpan_dir = join_path("cpanm", "cpanm")
if is_windows: if sys.platform == "win32":
maker = nmake maker = nmake
cpan_dir = join_path(self.stage.source_path, cpan_dir) cpan_dir = join_path(self.stage.source_path, cpan_dir)
if "+cpanm" in spec: if "+cpanm" in spec:
@ -352,7 +350,7 @@ def _setup_dependent_env(self, env, dependent_spec, deptype):
if perl_lib_dirs: if perl_lib_dirs:
perl_lib_path = ":".join(perl_lib_dirs) perl_lib_path = ":".join(perl_lib_dirs)
env.prepend_path("PERL5LIB", perl_lib_path) env.prepend_path("PERL5LIB", perl_lib_path)
if is_windows: if sys.platform == "win32":
env.append_path("PATH", self.prefix.bin) env.append_path("PATH", self.prefix.bin)
def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_build_environment(self, env, dependent_spec):
@ -382,7 +380,7 @@ def setup_dependent_package(self, module, dependent_spec):
mkdirp(module.perl_lib_dir) mkdirp(module.perl_lib_dir)
def setup_build_environment(self, env): def setup_build_environment(self, env):
if is_windows: if sys.platform == "win32":
env.append_path("PATH", self.prefix.bin) env.append_path("PATH", self.prefix.bin)
return return
@ -410,7 +408,7 @@ def filter_config_dot_pm(self):
frustrates filter_file on some filesystems (NFSv4), so make them frustrates filter_file on some filesystems (NFSv4), so make them
temporarily writable. temporarily writable.
""" """
if is_windows: if sys.platform == "win32":
return return
kwargs = {"ignore_absent": True, "backup": False, "string": False} kwargs = {"ignore_absent": True, "backup": False, "string": False}
@ -478,7 +476,7 @@ def command(self):
""" """
for ver in ("", self.spec.version): for ver in ("", self.spec.version):
ext = "" ext = ""
if is_windows: if sys.platform == "win32":
ext = ".exe" ext = ".exe"
path = os.path.join(self.prefix.bin, "{0}{1}{2}".format(self.spec.name, ver, ext)) path = os.path.join(self.prefix.bin, "{0}{1}{2}".format(self.spec.name, ver, ext))
if os.path.exists(path): if os.path.exists(path):

View File

@ -22,8 +22,6 @@
from spack.util.environment import is_system_path from spack.util.environment import is_system_path
from spack.util.prefix import Prefix from spack.util.prefix import Prefix
is_windows = sys.platform == "win32"
class Python(Package): class Python(Package):
"""The Python programming language.""" """The Python programming language."""
@ -125,12 +123,12 @@ class Python(Package):
# See https://legacy.python.org/dev/peps/pep-0394/ # See https://legacy.python.org/dev/peps/pep-0394/
variant( variant(
"pythoncmd", "pythoncmd",
default=not is_windows, default=sys.platform != "win32",
description="Symlink 'python3' executable to 'python' (not PEP 394 compliant)", description="Symlink 'python3' executable to 'python' (not PEP 394 compliant)",
) )
# Optional Python modules # Optional Python modules
variant("readline", default=not is_windows, description="Build readline module") variant("readline", default=sys.platform != "win32", description="Build readline module")
variant("ssl", default=True, description="Build ssl module") variant("ssl", default=True, description="Build ssl module")
variant("sqlite3", default=True, description="Build sqlite3 module") variant("sqlite3", default=True, description="Build sqlite3 module")
variant("dbm", default=True, description="Build dbm module") variant("dbm", default=True, description="Build dbm module")
@ -147,7 +145,7 @@ class Python(Package):
variant("crypt", default=True, description="Build crypt module", when="@:3.12 platform=darwin") variant("crypt", default=True, description="Build crypt module", when="@:3.12 platform=darwin")
variant("crypt", default=True, description="Build crypt module", when="@:3.12 platform=cray") variant("crypt", default=True, description="Build crypt module", when="@:3.12 platform=cray")
if not is_windows: if sys.platform != "win32":
depends_on("pkgconfig@0.9.0:", type="build") depends_on("pkgconfig@0.9.0:", type="build")
depends_on("gettext +libxml2", when="+libxml2") depends_on("gettext +libxml2", when="+libxml2")
depends_on("gettext ~libxml2", when="~libxml2") depends_on("gettext ~libxml2", when="~libxml2")
@ -298,7 +296,7 @@ def determine_variants(cls, exes, version_str):
variants += "~tix" variants += "~tix"
# Some modules are platform-dependent # Some modules are platform-dependent
if not is_windows: if sys.platform != "win32":
try: try:
python("-c", "import crypt", error=os.devnull) python("-c", "import crypt", error=os.devnull)
variants += "+crypt" variants += "+crypt"
@ -542,7 +540,7 @@ def configure(self, spec, prefix):
and an appropriately set prefix. and an appropriately set prefix.
""" """
with working_dir(self.stage.source_path, create=True): with working_dir(self.stage.source_path, create=True):
if is_windows: if sys.platform == "win32":
pass pass
else: else:
options = getattr(self, "configure_flag_args", []) options = getattr(self, "configure_flag_args", [])
@ -557,7 +555,7 @@ def build(self, spec, prefix):
# Windows builds use a batch script to drive # Windows builds use a batch script to drive
# configure and build in one step # configure and build in one step
with working_dir(self.stage.source_path): with working_dir(self.stage.source_path):
if is_windows: if sys.platform == "win32":
pcbuild_root = os.path.join(self.stage.source_path, "PCbuild") pcbuild_root = os.path.join(self.stage.source_path, "PCbuild")
builder_cmd = os.path.join(pcbuild_root, "build.bat") builder_cmd = os.path.join(pcbuild_root, "build.bat")
try: try:
@ -580,7 +578,7 @@ def install(self, spec, prefix):
:py:attr:``~.AutotoolsPackage.install_targets`` :py:attr:``~.AutotoolsPackage.install_targets``
""" """
with working_dir(self.stage.source_path): with working_dir(self.stage.source_path):
if is_windows: if sys.platform == "win32":
self.win_installer(prefix) self.win_installer(prefix)
else: else:
make(*self.install_targets) make(*self.install_targets)
@ -593,7 +591,7 @@ def filter_compilers(self):
If this isn't done, they'll have CC and CXX set to Spack's generic If this isn't done, they'll have CC and CXX set to Spack's generic
cc and c++. We want them to be bound to whatever compiler cc and c++. We want them to be bound to whatever compiler
they were built with.""" they were built with."""
if is_windows: if sys.platform == "win32":
return return
kwargs = {"ignore_absent": True, "backup": False, "string": True} kwargs = {"ignore_absent": True, "backup": False, "string": True}
@ -605,7 +603,7 @@ def filter_compilers(self):
@run_after("install") @run_after("install")
def symlink(self): def symlink(self):
if is_windows: if sys.platform == "win32":
return return
spec = self.spec spec = self.spec
prefix = self.prefix prefix = self.prefix
@ -723,7 +721,7 @@ def command(self):
# in that order if using python@3.11.0, for example. # in that order if using python@3.11.0, for example.
version = self.spec.version version = self.spec.version
for ver in [version.up_to(2), version.up_to(1), ""]: for ver in [version.up_to(2), version.up_to(1), ""]:
if not is_windows: if sys.platform != "win32":
path = os.path.join(self.prefix.bin, "python{0}".format(ver)) path = os.path.join(self.prefix.bin, "python{0}".format(ver))
else: else:
path = os.path.join(self.prefix, "python{0}.exe".format(ver)) path = os.path.join(self.prefix, "python{0}.exe".format(ver))
@ -772,11 +770,11 @@ def config_vars(self):
""" """
dag_hash = self.spec.dag_hash() dag_hash = self.spec.dag_hash()
lib_prefix = "lib" if not is_windows else "" lib_prefix = "lib" if sys.platform != "win32" else ""
if dag_hash not in self._config_vars: if dag_hash not in self._config_vars:
# Default config vars # Default config vars
version = self.version.up_to(2) version = self.version.up_to(2)
if is_windows: if sys.platform == "win32":
version = str(version).split(".")[0] version = str(version).split(".")[0]
config = { config = {
# get_config_vars # get_config_vars
@ -886,9 +884,9 @@ def find_library(self, library):
@property @property
def libs(self): def libs(self):
py_version = self.version.up_to(2) py_version = self.version.up_to(2)
if is_windows: if sys.platform == "win32":
py_version = str(py_version).replace(".", "") py_version = str(py_version).replace(".", "")
lib_prefix = "lib" if not is_windows else "" lib_prefix = "lib" if sys.platform != "win32" else ""
# The values of LDLIBRARY and LIBRARY aren't reliable. Intel Python uses a # The values of LDLIBRARY and LIBRARY aren't reliable. Intel Python uses a
# static binary but installs shared libraries, so sysconfig reports # static binary but installs shared libraries, so sysconfig reports
# libpythonX.Y.a but only libpythonX.Y.so exists. So we add our own paths, too. # libpythonX.Y.a but only libpythonX.Y.so exists. So we add our own paths, too.
@ -1121,7 +1119,7 @@ def setup_dependent_build_environment(self, env, dependent_spec):
# fact that LDSHARED is set in the environment, therefore we export # fact that LDSHARED is set in the environment, therefore we export
# the variable only if the new value is different from what we got # the variable only if the new value is different from what we got
# from the sysconfigdata file: # from the sysconfigdata file:
if config_link != new_link and not is_windows: if config_link != new_link and sys.platform != "win32":
env.set(link_var, new_link) env.set(link_var, new_link)
def setup_dependent_run_environment(self, env, dependent_spec): def setup_dependent_run_environment(self, env, dependent_spec):
@ -1180,7 +1178,7 @@ def add_files_to_view(self, view, merge_map, skip_if_exists=True):
view.link(new_link_target, dst, spec=self.spec) view.link(new_link_target, dst, spec=self.spec)
def remove_files_from_view(self, view, merge_map): def remove_files_from_view(self, view, merge_map):
bin_dir = self.spec.prefix.bin if not is_windows else self.spec.prefix bin_dir = self.spec.prefix.bin if sys.platform != "win32" else self.spec.prefix
for src, dst in merge_map.items(): for src, dst in merge_map.items():
if not path_contains_subdirectory(src, bin_dir): if not path_contains_subdirectory(src, bin_dir):
view.remove_file(src, dst) view.remove_file(src, dst)

View File

@ -7,8 +7,6 @@
from spack.package import * from spack.package import *
is_windows = sys.platform == "win32"
class Re2c(Package): class Re2c(Package):
"""re2c: a free and open-source lexer generator for C and C++""" """re2c: a free and open-source lexer generator for C and C++"""
@ -33,7 +31,7 @@ class Re2c(Package):
@property @property
def make_tool(self): def make_tool(self):
if is_windows: if sys.platform == "win32":
return ninja return ninja
else: else:
return make return make

View File

@ -6,8 +6,6 @@
from spack.package import * from spack.package import *
is_windows = sys.platform == "win32"
class Scons(PythonPackage): class Scons(PythonPackage):
"""SCons is a software construction tool""" """SCons is a software construction tool"""
@ -55,7 +53,7 @@ def setup_dependent_run_environment(self, env, dependent_spec):
env.prepend_path("PYTHONPATH", self.prefix.lib.scons) env.prepend_path("PYTHONPATH", self.prefix.lib.scons)
def setup_dependent_package(self, module, dspec): def setup_dependent_package(self, module, dspec):
if is_windows: if sys.platform == "win32":
module.scons = Executable(self.spec.prefix.Scripts.scons) module.scons = Executable(self.spec.prefix.Scripts.scons)
else: else:
module.scons = Executable(self.spec.prefix.bin.scons) module.scons = Executable(self.spec.prefix.bin.scons)

View File

@ -5,18 +5,16 @@
import glob import glob
import re import re
import sys
import time import time
from os.path import basename from os.path import basename
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
from sys import platform, stdout
from llnl.util import tty from llnl.util import tty
from spack.package import * from spack.package import *
is_windows = platform == "win32" if sys.platform != "win32":
if not is_windows:
from fcntl import F_GETFL, F_SETFL, fcntl from fcntl import F_GETFL, F_SETFL, fcntl
from os import O_NONBLOCK from os import O_NONBLOCK
@ -333,7 +331,7 @@ def configure(self, spec, prefix):
) )
p = Popen("./configure", stdin=PIPE, stdout=PIPE, stderr=PIPE) p = Popen("./configure", stdin=PIPE, stdout=PIPE, stderr=PIPE)
if not is_windows: if sys.platform != "win32":
setNonBlocking(p.stdout) setNonBlocking(p.stdout)
setNonBlocking(p.stderr) setNonBlocking(p.stderr)
@ -358,7 +356,7 @@ def configure(self, spec, prefix):
time.sleep(0.1) # Try to do a bit of rate limiting time.sleep(0.1) # Try to do a bit of rate limiting
stallcounter += 1 stallcounter += 1
continue continue
stdout.write(line) sys.stdout.write(line)
stallcounter = 0 stallcounter = 0
outputbuf += line outputbuf += line
if "Enter selection" in outputbuf or "Compile for nesting" in outputbuf: if "Enter selection" in outputbuf or "Compile for nesting" in outputbuf: