Repository: pre-commit/pre-commit

Issue:
cache + virtualenv>=20 / python_venv + moving executables -> File not found: ... python
failure mode looks something like this:

```
Check for added large files..............................................Failed
- hook id: check-added-large-files
- exit code: 1

Executable `/Users/runner/.cache/pre-commit/repo14qw_y0i/py_env-python3.8/bin/python` not found
```

currently this is a common failure for github actions caches, there's ~2 ways to work around this:

1. [add `$(which python)`](https://github.com/pre-commit/action/commit/ee269b64a608de770696d23079f46238c2f7ab5a) to the pre-commit cache key
2. [manually bump](https://github.com/pypa/pip/pull/7750/files) the pre-commit cache key

but pre-commit should more gracefully detect this in the [`healthy()`](https://github.com/pre-commit/pre-commit/blob/0a8ba31b9b6656d90f94fc368b47acb502cea44d/pre_commit/languages/python.py#L160-L168) function (which is designed to catch these sorts of system breakages)

Discussion:

Patch:
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index caa7794..5073a8b 100644
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -158,10 +158,12 @@ def py_interface(
             yield
 
     def healthy(prefix: Prefix, language_version: str) -> bool:
+        envdir = helpers.environment_dir(_dir, language_version)
+        exe_name = 'python.exe' if sys.platform == 'win32' else 'python'
+        py_exe = prefix.path(bin_dir(envdir), exe_name)
         with in_env(prefix, language_version):
             retcode, _, _ = cmd_output_b(
-                'python', '-c',
-                'import ctypes, datetime, io, os, ssl, weakref',
+                py_exe, '-c', 'import ctypes, datetime, io, os, ssl, weakref',
                 cwd='/',
                 retcode=None,
             )


Test patch:
diff --git a/tests/languages/python_test.py b/tests/languages/python_test.py
index 245c73a..34c6c7f 100644
--- a/tests/languages/python_test.py
+++ b/tests/languages/python_test.py
@@ -59,3 +59,17 @@ def test_healthy_types_py_in_cwd(tmpdir):
         # even if a `types.py` file exists, should still be healthy
         tmpdir.join('types.py').ensure()
         assert python.healthy(prefix, C.DEFAULT) is True
+
+
+def test_healthy_python_goes_missing(tmpdir):
+    with tmpdir.as_cwd():
+        prefix = tmpdir.join('prefix').ensure_dir()
+        prefix.join('setup.py').write('import setuptools; setuptools.setup()')
+        prefix = Prefix(str(prefix))
+        python.install_environment(prefix, C.DEFAULT, ())
+
+        exe_name = 'python' if sys.platform != 'win32' else 'python.exe'
+        py_exe = prefix.path(python.bin_dir('py_env-default'), exe_name)
+        os.remove(py_exe)
+
+        assert python.healthy(prefix, C.DEFAULT) is False