Skip to content

Commit 8812bb6

Browse files
committed
Provide better error message when patch is not available for pip hook
1 parent 127ab54 commit 8812bb6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graalpython/lib-graalpython/pip_hook.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,11 @@ def apply_first_existing(dir, suffix, wd=None):
222222
filename = first_existing(package_name, name_ver_match, dir, suffix)
223223
if filename:
224224
print("Patching package " + package_name + " using " + filename)
225-
patch_res = subprocess.run(["patch", "-f", "-d", location, "-p1", "-i", filename], cwd=wd)
226-
if patch_res.returncode != 0:
225+
try:
226+
subprocess.run(["patch", "-f", "-d", location, "-p1", "-i", filename], cwd=wd, check=True)
227+
except FileNotFoundError:
228+
print("WARNING: GraalPy needs the 'patch' utility to apply compatibility patches. Please install it using your system's package manager.")
229+
except subprocess.CalledProcessError:
227230
print("Applying GraalPy patch failed for %s. The package may still work." % package_name)
228231
elif os.path.isdir(dir):
229232
patchfiles = [f for f in os.listdir(dir) if re.match("{0}{1}$".format(NAME_VER_PATTERN, suffix), f)]

0 commit comments

Comments
 (0)