From 4ff8a6a9b703002db9f1c5a949a4b00c4978363d Mon Sep 17 00:00:00 2001 From: 百地 希留耶 <65301509+KiruyaMomochi@users.noreply.github.com> Date: Thu, 27 Oct 2022 04:45:35 +0800 Subject: Windows: fix bootstrap and package install failure (#32942) * Add patches for building clingo with MSVC * Help python find clingo DLL * If an executable is located in "C:\Program Files", Executable was running into issues with the extra space. This quotes the exe to ensure that it is treated as a single value. Signed-off-by: Kiruya Momochi <65301509+KiruyaMomochi@users.noreply.github.com> --- lib/spack/spack/bootstrap.py | 8 ++++++++ lib/spack/spack/util/executable.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py index 2e0f2614e7..d92609fdcd 100644 --- a/lib/spack/spack/bootstrap.py +++ b/lib/spack/spack/bootstrap.py @@ -91,6 +91,14 @@ def _try_import_from_store(module, query_spec, query_info=None): os.path.join(candidate_spec.prefix, pkg.platlib), ] # type: list[str] path_before = list(sys.path) + + # Python 3.8+ on Windows does not search dependent DLLs in PATH, + # so we need to manually add it using os.add_dll_directory + # https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew + if sys.version_info[:2] >= (3, 8) and sys.platform == "win32": + if os.path.isdir(candidate_spec.prefix.bin): + os.add_dll_directory(candidate_spec.prefix.bin) # novermin + # NOTE: try module_paths first and last, last allows an existing version in path # to be picked up and used, possibly depending on something in the store, first # allows the bootstrap version to work when an incompatible version is in diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index cd8ddef6de..6160b95266 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -10,6 +10,7 @@ import subprocess import sys from six import string_types, text_type +from six.moves import shlex_quote import llnl.util.tty as tty @@ -333,7 +334,7 @@ def which(*args, **kwargs): Executable: The first executable that is found in the path """ exe = which_string(*args, **kwargs) - return Executable(exe) if exe else None + return Executable(shlex_quote(exe)) if exe else None class ProcessError(spack.error.SpackError): -- cgit v1.2.3-70-g09d2