summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2023-10-24 19:37:26 -0400
committerGitHub <noreply@github.com>2023-10-24 16:37:26 -0700
commite1da9339d9a512a040fc6aab18d85912432f2b58 (patch)
tree7608b5f0b38d9c777a3f9ddce6b4727ff77ab84a /lib
parent2d203df075581204b552ec8e9bf131ec587974e6 (diff)
downloadspack-e1da9339d9a512a040fc6aab18d85912432f2b58.tar.gz
spack-e1da9339d9a512a040fc6aab18d85912432f2b58.tar.bz2
spack-e1da9339d9a512a040fc6aab18d85912432f2b58.tar.xz
spack-e1da9339d9a512a040fc6aab18d85912432f2b58.zip
Windows: search PATH for patch utility (#40513)
Previously, we only searched for `patch` inside of whatever Git installation was available because the most common installation of Git available on Windows had `patch`. That's not true for all possible installations of Git though, so this updates the search to also check PATH.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/patch.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index 8b094a7642..7e2fcaff10 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -7,6 +7,7 @@ import hashlib
import inspect
import os
import os.path
+import pathlib
import sys
import llnl.util.filesystem
@@ -36,10 +37,12 @@ def apply_patch(stage, patch_path, level=1, working_dir="."):
"""
git_utils_path = os.environ.get("PATH", "")
if sys.platform == "win32":
- git = which_string("git", required=True)
- git_root = git.split("\\")[:-2]
- git_root.extend(["usr", "bin"])
- git_utils_path = os.sep.join(git_root)
+ git = which_string("git")
+ if git:
+ git = pathlib.Path(git)
+ git_root = git.parent.parent
+ git_root = git_root / "usr" / "bin"
+ git_utils_path = os.pathsep.join([str(git_root), git_utils_path])
# TODO: Decouple Spack's patch support on Windows from Git
# for Windows, and instead have Spack directly fetch, install, and