Unverified Commit 30b34ac0 authored by Ben Siraphob's avatar Ben Siraphob Committed by GitHub
Browse files

Merge pull request #267499 from NilsIrl/pygrep-pythonpath

[pre-commit] Forward sys.path to pygrep via PYTHONPATH
parents 30722c14 69d78abd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ buildPythonApplication rec {
  patches = [
    ./languages-use-the-hardcoded-path-to-python-binaries.patch
    ./hook-tmpl.patch
    ./pygrep-pythonpath.patch
  ];

  propagatedBuildInputs = [
+13 −0
Original line number Diff line number Diff line
diff --git a/pre_commit/languages/pygrep.py b/pre_commit/languages/pygrep.py
index ec55560..44e08a1 100644
--- a/pre_commit/languages/pygrep.py
+++ b/pre_commit/languages/pygrep.py
@@ -98,7 +98,7 @@ def run_hook(
         color: bool,
 ) -> tuple[int, bytes]:
     cmd = (sys.executable, '-m', __name__, *args, entry)
-    return xargs(cmd, file_args, color=color)
+    return xargs(cmd, file_args, color=color, env={ "PYTHONPATH": ':'.join(sys.path) })
 
 
 def main(argv: Sequence[str] | None = None) -> int: