diff options
author | Dan Lipsa <dan.lipsa@kitware.com> | 2023-02-07 14:04:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 11:04:14 -0800 |
commit | 16489685141dc991806c49c85453bcd6310a9f51 (patch) | |
tree | 9f7560492fbb0ca6def867a8a748491b86e205ad /lib | |
parent | 8358f430a4094f2924b4026359f6691306114798 (diff) | |
download | spack-16489685141dc991806c49c85453bcd6310a9f51.tar.gz spack-16489685141dc991806c49c85453bcd6310a9f51.tar.bz2 spack-16489685141dc991806c49c85453bcd6310a9f51.tar.xz spack-16489685141dc991806c49c85453bcd6310a9f51.zip |
Windows: Fix spack.bat handling of env commands (#35143)
This PR enables the successful execution of the spack binary cache
tutorial on Windows. It assumes gnupg and file are available (they
can be installed with choco).
* Fix handling of args with quotes in spack.bat
* `file` utility can be installed on Windows (e.g. with choco): update
error message accordingly
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 8581081e48..b39a17b52a 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -23,7 +23,7 @@ from llnl.util import tty from llnl.util.lang import dedupe, memoized from llnl.util.symlink import islink, symlink -from spack.util.executable import CommandNotFoundError, Executable, which +from spack.util.executable import Executable, which from spack.util.path import path_to_os_path, system_path_filter is_windows = _platform == "win32" @@ -117,13 +117,7 @@ def path_contains_subdirectory(path, root): @memoized def file_command(*args): """Creates entry point to `file` system command with provided arguments""" - try: - file_cmd = which("file", required=True) - except CommandNotFoundError as e: - if is_windows: - raise CommandNotFoundError("`file` utility is not available on Windows") - else: - raise e + file_cmd = which("file", required=True) for arg in args: file_cmd.add_default_arg(arg) return file_cmd @@ -134,7 +128,11 @@ def _get_mime_type(): """Generate method to call `file` system command to aquire mime type for a specified path """ - return file_command("-b", "-h", "--mime-type") + if is_windows: + # -h option (no-dereference) does not exist in Windows + return file_command("-b", "--mime-type") + else: + return file_command("-b", "-h", "--mime-type") @memoized |