We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Not working on macOS Sierra?
Attempting to utilize a collection of hooks from the default repo, I get the following:

```
An unexpected error has occurred: CalledProcessError: Command: ('/Users/amcgregor/Projects/marrow/.venv/bin/python3', '-m', 'virtualenv', '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')
Return code: 100
Expected return code: 0
Output: 
    Using base prefix '/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/3.5'
    New python executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3
    Also creating executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python
    ERROR: The executable /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3 is not functioning
    ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.5' (should be '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')
    ERROR: virtualenv is not compatible with this system or executable

Errors: (none)

Traceback (most recent call last):
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/error_handler.py", line 47, in error_handler
    yield
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/main.py", line 157, in main
    return run(runner, args)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py", line 212, in run
    return _run_hooks(repo_hooks, args, write, environ)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/staged_files_only.py", line 63, in staged_files_only
    yield
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py", line 195, in run
    repo_hooks = list(get_repo_hooks(runner))
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py", line 141, in get_repo_hooks
    for repo in runner.repositories:
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/cached_property.py", line 26, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/runner.py", line 47, in repositories
    repository.require_installed()
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/repository.py", line 117, in require_installed
    self.install()
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/repository.py", line 187, in install
    self.additional_dependencies[language_name][language_version],
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/languages/python.py", line 78, in install_environment
    ('pip', 'install', '.') + additional_dependencies,
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/util.py", line 58, in clean_path_on_failure
    yield
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/languages/python.py", line 74, in install_environment
    repo_cmd_runner.run(venv_cmd)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/prefixed_command_runner.py", line 39, in run
    return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)
  File "/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/util.py", line 189, in cmd_output
    returncode, cmd, retcode, output=(stdout, stderr),
pre_commit.util.CalledProcessError: Command: ('/Users/amcgregor/Projects/marrow/.venv/bin/python3', '-m', 'virtualenv', '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')
Return code: 100
Expected return code: 0
Output: 
    Using base prefix '/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/3.5'
    New python executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3
    Also creating executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python
    ERROR: The executable /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3 is not functioning
    ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.5' (should be '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')
    ERROR: virtualenv is not compatible with this system or executable

Errors: (none)
```

Using the Python.org-provided Python 3.5 installer package.  I'm already within a virtual environment at the point of execution.


--- 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 import sys
7 
8 from pre_commit.envcontext import envcontext
9 from pre_commit.envcontext import UNSET
10 from pre_commit.envcontext import Var
11 from pre_commit.languages import helpers
12 from pre_commit.util import clean_path_on_failure
13 from pre_commit.xargs import xargs
14 
15 
16 ENVIRONMENT_DIR = 'py_env'
17 
18 
19 def bin_dir(venv):
20     """On windows there's a different directory for the virtualenv"""
21     bin_part = 'Scripts' if os.name == 'nt' else 'bin'
22     return os.path.join(venv, bin_part)
23 
24 
25 def get_env_patch(venv):
26     return (
27         ('PYTHONHOME', UNSET),
28         ('VIRTUAL_ENV', venv),
29         ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
30     )
31 
32 
33 @contextlib.contextmanager
34 def in_env(repo_cmd_runner, language_version):
35     envdir = os.path.join(
36         repo_cmd_runner.prefix_dir,
37         helpers.environment_dir(ENVIRONMENT_DIR, language_version),
38     )
39     with envcontext(get_env_patch(envdir)):
40         yield
41 
42 
43 def norm_version(version):
44     if os.name == 'nt':  # pragma: no cover (windows)
45         # Try looking up by name
46         if distutils.spawn.find_executable(version):
47             return version
48 
49         # If it is in the form pythonx.x search in the default
50         # place on windows
51         if version.startswith('python'):
52             return r'C:\{}\python.exe'.format(version.replace('.', ''))
53 
54         # Otherwise assume it is a path
55     return os.path.expanduser(version)
56 
57 
58 def install_environment(
59         repo_cmd_runner,
60         version='default',
61         additional_dependencies=(),
62 ):
63     additional_dependencies = tuple(additional_dependencies)
64     directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
65 
66     # Install a virtualenv
67     with clean_path_on_failure(repo_cmd_runner.path(directory)):
68         venv_cmd = [
69             sys.executable, '-m', 'virtualenv',
70             '{{prefix}}{}'.format(directory)
71         ]
72         if version != 'default':
73             venv_cmd.extend(['-p', norm_version(version)])
74         repo_cmd_runner.run(venv_cmd)
75         with in_env(repo_cmd_runner, version):
76             helpers.run_setup_cmd(
77                 repo_cmd_runner,
78                 ('pip', 'install', '.') + additional_dependencies,
79             )
80 
81 
82 def run_hook(repo_cmd_runner, hook, file_args):
83     with in_env(repo_cmd_runner, hook['language_version']):
84         return xargs((hook['entry'],) + tuple(hook['args']), file_args)
85
```
--- 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()

```

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
@@ -71,6 +71,8 @@
         ]
         if version != 'default':
             venv_cmd.extend(['-p', norm_version(version)])
+        else:
+            venv_cmd.extend(['-p', os.path.realpath(sys.executable)])
         repo_cmd_runner.run(venv_cmd)
         with in_env(repo_cmd_runner, version):
             helpers.run_setup_cmd(

{"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@@ -71,6 +71,8 @@\n         ]\n         if version != 'default':\n             venv_cmd.extend(['-p', norm_version(version)])\n+        else:\n+            venv_cmd.extend(['-p', os.path.realpath(sys.executable)])\n         repo_cmd_runner.run(venv_cmd)\n         with in_env(repo_cmd_runner, version):\n             helpers.run_setup_cmd(\n", "issue": "Not working on macOS Sierra?\nAttempting to utilize a collection of hooks from the default repo, I get the following:\n\n```\nAn unexpected error has occurred: CalledProcessError: Command: ('/Users/amcgregor/Projects/marrow/.venv/bin/python3', '-m', 'virtualenv', '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')\nReturn code: 100\nExpected return code: 0\nOutput: \n    Using base prefix '/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/3.5'\n    New python executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3\n    Also creating executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python\n    ERROR: The executable /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3 is not functioning\n    ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.5' (should be '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')\n    ERROR: virtualenv is not compatible with this system or executable\n\nErrors: (none)\n\nTraceback (most recent call last):\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/error_handler.py\", line 47, in error_handler\n    yield\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/main.py\", line 157, in main\n    return run(runner, args)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py\", line 212, in run\n    return _run_hooks(repo_hooks, args, write, environ)\n  File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py\", line 77, in __exit__\n    self.gen.throw(type, value, traceback)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/staged_files_only.py\", line 63, in staged_files_only\n    yield\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py\", line 195, in run\n    repo_hooks = list(get_repo_hooks(runner))\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/commands/run.py\", line 141, in get_repo_hooks\n    for repo in runner.repositories:\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/cached_property.py\", line 26, in __get__\n    value = obj.__dict__[self.func.__name__] = self.func(obj)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/runner.py\", line 47, in repositories\n    repository.require_installed()\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/repository.py\", line 117, in require_installed\n    self.install()\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/repository.py\", line 187, in install\n    self.additional_dependencies[language_name][language_version],\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/languages/python.py\", line 78, in install_environment\n    ('pip', 'install', '.') + additional_dependencies,\n  File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py\", line 77, in __exit__\n    self.gen.throw(type, value, traceback)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/util.py\", line 58, in clean_path_on_failure\n    yield\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/languages/python.py\", line 74, in install_environment\n    repo_cmd_runner.run(venv_cmd)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/prefixed_command_runner.py\", line 39, in run\n    return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)\n  File \"/Users/amcgregor/Projects/marrow/.venv/lib/python3.5/site-packages/pre_commit/util.py\", line 189, in cmd_output\n    returncode, cmd, retcode, output=(stdout, stderr),\npre_commit.util.CalledProcessError: Command: ('/Users/amcgregor/Projects/marrow/.venv/bin/python3', '-m', 'virtualenv', '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')\nReturn code: 100\nExpected return code: 0\nOutput: \n    Using base prefix '/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/3.5'\n    New python executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3\n    Also creating executable in /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python\n    ERROR: The executable /Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default/bin/python3 is not functioning\n    ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.5' (should be '/Users/amcgregor/.pre-commit/repofu57ylaa/py_env-default')\n    ERROR: virtualenv is not compatible with this system or executable\n\nErrors: (none)\n```\n\nUsing the Python.org-provided Python 3.5 installer package.  I'm already within a virtual environment at the point of execution.\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport contextlib\nimport distutils.spawn\nimport os\nimport sys\n\nfrom pre_commit.envcontext import envcontext\nfrom pre_commit.envcontext import UNSET\nfrom pre_commit.envcontext import Var\nfrom pre_commit.languages import helpers\nfrom pre_commit.util import clean_path_on_failure\nfrom pre_commit.xargs import xargs\n\n\nENVIRONMENT_DIR = 'py_env'\n\n\ndef bin_dir(venv):\n    \"\"\"On windows there's a different directory for the virtualenv\"\"\"\n    bin_part = 'Scripts' if os.name == 'nt' else 'bin'\n    return os.path.join(venv, bin_part)\n\n\ndef get_env_patch(venv):\n    return (\n        ('PYTHONHOME', UNSET),\n        ('VIRTUAL_ENV', venv),\n        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),\n    )\n\n\n@contextlib.contextmanager\ndef in_env(repo_cmd_runner, language_version):\n    envdir = os.path.join(\n        repo_cmd_runner.prefix_dir,\n        helpers.environment_dir(ENVIRONMENT_DIR, language_version),\n    )\n    with envcontext(get_env_patch(envdir)):\n        yield\n\n\ndef norm_version(version):\n    if os.name == 'nt':  # pragma: no cover (windows)\n        # Try looking up by name\n        if distutils.spawn.find_executable(version):\n            return version\n\n        # If it is in the form pythonx.x search in the default\n        # place on windows\n        if version.startswith('python'):\n            return r'C:\\{}\\python.exe'.format(version.replace('.', ''))\n\n        # Otherwise assume it is a path\n    return os.path.expanduser(version)\n\n\ndef install_environment(\n        repo_cmd_runner,\n        version='default',\n        additional_dependencies=(),\n):\n    additional_dependencies = tuple(additional_dependencies)\n    directory = helpers.environment_dir(ENVIRONMENT_DIR, version)\n\n    # Install a virtualenv\n    with clean_path_on_failure(repo_cmd_runner.path(directory)):\n        venv_cmd = [\n            sys.executable, '-m', 'virtualenv',\n            '{{prefix}}{}'.format(directory)\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, version):\n            helpers.run_setup_cmd(\n                repo_cmd_runner,\n                ('pip', 'install', '.') + additional_dependencies,\n            )\n\n\ndef run_hook(repo_cmd_runner, hook, file_args):\n    with in_env(repo_cmd_runner, hook['language_version']):\n        return xargs((hook['entry'],) + tuple(hook['args']), 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\nfrom pre_commit.envcontext import envcontext\nfrom pre_commit.envcontext import UNSET\nfrom pre_commit.envcontext import Var\nfrom pre_commit.languages import helpers\nfrom pre_commit.util import clean_path_on_failure\nfrom pre_commit.xargs import xargs\n\n\nENVIRONMENT_DIR = 'py_env'\n\n\ndef bin_dir(venv):\n    \"\"\"On windows there's a different directory for the virtualenv\"\"\"\n    bin_part = 'Scripts' if os.name == 'nt' else 'bin'\n    return os.path.join(venv, bin_part)\n\n\ndef get_env_patch(venv):\n    return (\n        ('PYTHONHOME', UNSET),\n        ('VIRTUAL_ENV', venv),\n        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),\n    )\n\n\n@contextlib.contextmanager\ndef in_env(repo_cmd_runner, language_version):\n    envdir = os.path.join(\n        repo_cmd_runner.prefix_dir,\n        helpers.environment_dir(ENVIRONMENT_DIR, language_version),\n    )\n    with envcontext(get_env_patch(envdir)):\n        yield\n\n\ndef norm_version(version):\n    if os.name == 'nt':  # pragma: no cover (windows)\n        # Try looking up by name\n        if distutils.spawn.find_executable(version):\n            return version\n\n        # If it is in the form pythonx.x search in the default\n        # place on windows\n        if version.startswith('python'):\n            return r'C:\\{}\\python.exe'.format(version.replace('.', ''))\n\n        # Otherwise assume it is a path\n    return os.path.expanduser(version)\n\n\ndef install_environment(\n        repo_cmd_runner,\n        version='default',\n        additional_dependencies=(),\n):\n    additional_dependencies = tuple(additional_dependencies)\n    directory = helpers.environment_dir(ENVIRONMENT_DIR, version)\n\n    # Install a virtualenv\n    with clean_path_on_failure(repo_cmd_runner.path(directory)):\n        venv_cmd = [\n            sys.executable, '-m', 'virtualenv',\n            '{{prefix}}{}'.format(directory)\n        ]\n        if version != 'default':\n            venv_cmd.extend(['-p', norm_version(version)])\n        else:\n            venv_cmd.extend(['-p', os.path.realpath(sys.executable)])\n        repo_cmd_runner.run(venv_cmd)\n        with in_env(repo_cmd_runner, version):\n            helpers.run_setup_cmd(\n                repo_cmd_runner,\n                ('pip', 'install', '.') + additional_dependencies,\n            )\n\n\ndef run_hook(repo_cmd_runner, hook, file_args):\n    with in_env(repo_cmd_runner, hook['language_version']):\n        return xargs((hook['entry'],) + tuple(hook['args']), file_args)\n", "path": "pre_commit/languages/python.py"}]}