prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  pre-commit potentially uses the wrong `virtualenv` when building environments
  It should use `sys.executable, '-m', 'virtualenv'` instead of `'virtualenv'`
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pre_commit/languages/python.py`
  Content:
  ```
  1 from __future__ import unicode_literals
  2 
  3 import contextlib
  4 import distutils.spawn
  5 import os
  6 
  7 import virtualenv
  8 
  9 from pre_commit.languages import helpers
  10 from pre_commit.util import clean_path_on_failure
  11 
  12 
  13 ENVIRONMENT_DIR = 'py_env'
  14 
  15 
  16 class PythonEnv(helpers.Environment):
  17     @property
  18     def env_prefix(self):
  19         return ". '{{prefix}}{0}activate' &&".format(
  20             virtualenv.path_locations(
  21                 ENVIRONMENT_DIR,
  22             )[-1].rstrip(os.sep) + os.sep,
  23             'activate',
  24         )
  25 
  26 
  27 @contextlib.contextmanager
  28 def in_env(repo_cmd_runner):
  29     yield PythonEnv(repo_cmd_runner)
  30 
  31 
  32 def norm_version(version):
  33     if os.name == 'nt':  # pragma: no cover (windows)
  34         if not distutils.spawn.find_executable(version):
  35             # The default place for python on windows is:
  36             # C:\PythonXX\python.exe
  37             version = r'C:\{0}\python.exe'.format(version.replace('.', ''))
  38     return version
  39 
  40 
  41 def install_environment(repo_cmd_runner, version='default'):
  42     assert repo_cmd_runner.exists('setup.py')
  43 
  44     # Install a virtualenv
  45     with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)):
  46         venv_cmd = ['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)]
  47         if version != 'default':
  48             venv_cmd.extend(['-p', norm_version(version)])
  49         repo_cmd_runner.run(venv_cmd)
  50         with in_env(repo_cmd_runner) as env:
  51             env.run("cd '{prefix}' && pip install .")
  52 
  53 
  54 def run_hook(repo_cmd_runner, hook, file_args):
  55     with in_env(repo_cmd_runner) as env:
  56         return helpers.run_hook(env, hook, file_args)
  57
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
  --- a/pre_commit/languages/python.py
  +++ b/pre_commit/languages/python.py
  @@ -3,6 +3,7 @@
   import contextlib
   import distutils.spawn
   import os
  +import sys
   
   import virtualenv
   
  @@ -43,7 +44,10 @@
   
       # Install a virtualenv
       with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)):
  -        venv_cmd = ['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)]
  +        venv_cmd = [
  +            sys.executable, '-m', 'virtualenv',
  +            '{{prefix}}{0}'.format(ENVIRONMENT_DIR)
  +        ]
           if version != 'default':
               venv_cmd.extend(['-p', norm_version(version)])
           repo_cmd_runner.run(venv_cmd)
  
verification_info: {"golden_diff": "diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py\n--- a/pre_commit/languages/python.py\n+++ b/pre_commit/languages/python.py\n@@ -3,6 +3,7 @@\n import contextlib\n import distutils.spawn\n import os\n+import sys\n \n import virtualenv\n \n@@ -43,7 +44,10 @@\n \n     # Install a virtualenv\n     with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)):\n-        venv_cmd = ['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)]\n+        venv_cmd = [\n+            sys.executable, '-m', 'virtualenv',\n+            '{{prefix}}{0}'.format(ENVIRONMENT_DIR)\n+        ]\n         if version != 'default':\n             venv_cmd.extend(['-p', norm_version(version)])\n         repo_cmd_runner.run(venv_cmd)\n", "issue": "pre-commit potentially uses the wrong `virtualenv` when building environments\nIt should use `sys.executable, '-m', 'virtualenv'` instead of `'virtualenv'`\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport contextlib\nimport distutils.spawn\nimport os\n\nimport virtualenv\n\nfrom pre_commit.languages import helpers\nfrom pre_commit.util import clean_path_on_failure\n\n\nENVIRONMENT_DIR = 'py_env'\n\n\nclass PythonEnv(helpers.Environment):\n    @property\n    def env_prefix(self):\n        return \". '{{prefix}}{0}activate' &&\".format(\n            virtualenv.path_locations(\n                ENVIRONMENT_DIR,\n            )[-1].rstrip(os.sep) + os.sep,\n            'activate',\n        )\n\n\n@contextlib.contextmanager\ndef in_env(repo_cmd_runner):\n    yield PythonEnv(repo_cmd_runner)\n\n\ndef norm_version(version):\n    if os.name == 'nt':  # pragma: no cover (windows)\n        if not distutils.spawn.find_executable(version):\n            # The default place for python on windows is:\n            # C:\\PythonXX\\python.exe\n            version = r'C:\\{0}\\python.exe'.format(version.replace('.', ''))\n    return version\n\n\ndef install_environment(repo_cmd_runner, version='default'):\n    assert repo_cmd_runner.exists('setup.py')\n\n    # Install a virtualenv\n    with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)):\n        venv_cmd = ['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)]\n        if version != 'default':\n            venv_cmd.extend(['-p', norm_version(version)])\n        repo_cmd_runner.run(venv_cmd)\n        with in_env(repo_cmd_runner) as env:\n            env.run(\"cd '{prefix}' && pip install .\")\n\n\ndef run_hook(repo_cmd_runner, hook, file_args):\n    with in_env(repo_cmd_runner) as env:\n        return helpers.run_hook(env, hook, file_args)\n", "path": "pre_commit/languages/python.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nimport contextlib\nimport distutils.spawn\nimport os\nimport sys\n\nimport virtualenv\n\nfrom pre_commit.languages import helpers\nfrom pre_commit.util import clean_path_on_failure\n\n\nENVIRONMENT_DIR = 'py_env'\n\n\nclass PythonEnv(helpers.Environment):\n    @property\n    def env_prefix(self):\n        return \". '{{prefix}}{0}activate' &&\".format(\n            virtualenv.path_locations(\n                ENVIRONMENT_DIR,\n            )[-1].rstrip(os.sep) + os.sep,\n            'activate',\n        )\n\n\n@contextlib.contextmanager\ndef in_env(repo_cmd_runner):\n    yield PythonEnv(repo_cmd_runner)\n\n\ndef norm_version(version):\n    if os.name == 'nt':  # pragma: no cover (windows)\n        if not distutils.spawn.find_executable(version):\n            # The default place for python on windows is:\n            # C:\\PythonXX\\python.exe\n            version = r'C:\\{0}\\python.exe'.format(version.replace('.', ''))\n    return version\n\n\ndef install_environment(repo_cmd_runner, version='default'):\n    assert repo_cmd_runner.exists('setup.py')\n\n    # Install a virtualenv\n    with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)):\n        venv_cmd = [\n            sys.executable, '-m', 'virtualenv',\n            '{{prefix}}{0}'.format(ENVIRONMENT_DIR)\n        ]\n        if version != 'default':\n            venv_cmd.extend(['-p', norm_version(version)])\n        repo_cmd_runner.run(venv_cmd)\n        with in_env(repo_cmd_runner) as env:\n            env.run(\"cd '{prefix}' && pip install .\")\n\n\ndef run_hook(repo_cmd_runner, hook, file_args):\n    with in_env(repo_cmd_runner) as env:\n        return helpers.run_hook(env, hook, file_args)\n", "path": "pre_commit/languages/python.py"}]}