We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
setup.cfg prevent pre-commit to install
For some reason I have a setup.cfg file in the root directory of my repo for my app where the parameter **install_scripts** is set to **/usr/sbin**. This prevent pre-commit to set up and crash.
Here is a repro in a fresh git repository containing only **setup.cfg** file and **.pre-commit-config.yaml** (for the [install guide](http://pre-commit.com/#install)

<pre>
$ mkdir repro; cd repro
$ git init
Dépôt Git vide initialisé dans /home/wilfried/repro/.git/
$ pre-commit clean
Cleaned /home/wilfried/.pre-commit.
$ pre-commit install
pre-commit installed at /home/wilfried/repro/.git/hooks/pre-commit
$ cat setup.cfg 
[install]
install_scripts=/usr/sbin
$ cat .pre-commit-config.yaml 
-   repo: git://github.com/pre-commit/pre-commit-hooks
    sha: v0.4.2
    hooks:
    -   id: trailing-whitespace
</pre>

Now, with those two files setup, I try to run a simple pre-commit run which try to initiate the virtualenv.
<pre>
$ pre-commit run --all-files
[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/python', '-m', 'virtualenv', '/home/wilfried/.pre-commit/repoaXLSIv/py_env-default', '-p', '/usr/bin/python2.7')
Return code: 1
Expected return code: 0
Output: 
    New python executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python2.7
    Also creating executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python
    Installing setuptools, pip, wheel...
      Complete output from command /home/wilfried/.pre-...efault/bin/python2.7 - setuptools pip wheel:
    ...Installing setuptools, pip, wheel...done.
    Running virtualenv with interpreter /usr/bin/python2.7
    
Errors: 
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2327, in <module>
        main()
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 711, in main
        symlink=options.symlink)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 944, in create_environment
        download=download,
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 900, in install_wheel
        call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 792, in call_subprocess
        logger.notify('\n'.join(all_output) + '\n----------------------------------------')
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 199, in notify
        self.log(self.NOTIFY, msg, *args, **kw)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 231, in log
        consumer.write(rendered+'\n')
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2254: ordinal not in range(128)
    

Check the log at ~/.pre-commit/pre-commit.log
</pre>

You'll find the content on pre-commit.log on [pastebin](http://pastebin.com/Ls61EQDj).

Now the if I comment out the install_scripts parameter, everything works fine

<pre>
$ cat setup.cfg 
[install]
#install_scripts=/usr/sbin
$ pre-commit clean
Cleaned /home/wilfried/.pre-commit.
$ pre-commit run --all-files
[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Trim Trailing Whitespace.............................(no files to check)Skipped
</pre>

I'm running on a linux mint 18, with python 2.7.12 and pre-commit 0.9.2
<pre>
$ python --version
Python 2.7.12
$ pre-commit --version
pre-commit 0.9.2
</pre>

Let my know if you need anything else.

--- 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         else:
75             venv_cmd.extend(['-p', os.path.realpath(sys.executable)])
76         repo_cmd_runner.run(venv_cmd)
77         with in_env(repo_cmd_runner, version):
78             helpers.run_setup_cmd(
79                 repo_cmd_runner,
80                 ('pip', 'install', '.') + additional_dependencies,
81             )
82 
83 
84 def run_hook(repo_cmd_runner, hook, file_args):
85     with in_env(repo_cmd_runner, hook['language_version']):
86         return xargs((hook['entry'],) + tuple(hook['args']), file_args)
87
```
--- 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
@@ -73,7 +73,7 @@
             venv_cmd.extend(['-p', norm_version(version)])
         else:
             venv_cmd.extend(['-p', os.path.realpath(sys.executable)])
-        repo_cmd_runner.run(venv_cmd)
+        repo_cmd_runner.run(venv_cmd, cwd='/')
         with in_env(repo_cmd_runner, version):
             helpers.run_setup_cmd(
                 repo_cmd_runner,

{"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@@ -73,7 +73,7 @@\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+        repo_cmd_runner.run(venv_cmd, cwd='/')\n         with in_env(repo_cmd_runner, version):\n             helpers.run_setup_cmd(\n                 repo_cmd_runner,\n", "issue": "setup.cfg prevent pre-commit to install\nFor some reason I have a setup.cfg file in the root directory of my repo for my app where the parameter **install_scripts** is set to **/usr/sbin**. This prevent pre-commit to set up and crash.\r\nHere is a repro in a fresh git repository containing only **setup.cfg** file and **.pre-commit-config.yaml** (for the [install guide](http://pre-commit.com/#install)\r\n\r\n<pre>\r\n$ mkdir repro; cd repro\r\n$ git init\r\nD\u00e9p\u00f4t Git vide initialis\u00e9 dans /home/wilfried/repro/.git/\r\n$ pre-commit clean\r\nCleaned /home/wilfried/.pre-commit.\r\n$ pre-commit install\r\npre-commit installed at /home/wilfried/repro/.git/hooks/pre-commit\r\n$ cat setup.cfg \r\n[install]\r\ninstall_scripts=/usr/sbin\r\n$ cat .pre-commit-config.yaml \r\n-   repo: git://github.com/pre-commit/pre-commit-hooks\r\n    sha: v0.4.2\r\n    hooks:\r\n    -   id: trailing-whitespace\r\n</pre>\r\n\r\nNow, with those two files setup, I try to run a simple pre-commit run which try to initiate the virtualenv.\r\n<pre>\r\n$ pre-commit run --all-files\r\n[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Once installed this environment will be reused.\r\n[INFO] This may take a few minutes...\r\nAn unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/python', '-m', 'virtualenv', '/home/wilfried/.pre-commit/repoaXLSIv/py_env-default', '-p', '/usr/bin/python2.7')\r\nReturn code: 1\r\nExpected return code: 0\r\nOutput: \r\n    New python executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python2.7\r\n    Also creating executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python\r\n    Installing setuptools, pip, wheel...\r\n      Complete output from command /home/wilfried/.pre-...efault/bin/python2.7 - setuptools pip wheel:\r\n    ...Installing setuptools, pip, wheel...done.\r\n    Running virtualenv with interpreter /usr/bin/python2.7\r\n    \r\nErrors: \r\n    Traceback (most recent call last):\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 2327, in <module>\r\n        main()\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 711, in main\r\n        symlink=options.symlink)\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 944, in create_environment\r\n        download=download,\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 900, in install_wheel\r\n        call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 792, in call_subprocess\r\n        logger.notify('\\n'.join(all_output) + '\\n----------------------------------------')\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 199, in notify\r\n        self.log(self.NOTIFY, msg, *args, **kw)\r\n      File \"/usr/local/lib/python2.7/dist-packages/virtualenv.py\", line 231, in log\r\n        consumer.write(rendered+'\\n')\r\n    UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe9' in position 2254: ordinal not in range(128)\r\n    \r\n\r\nCheck the log at ~/.pre-commit/pre-commit.log\r\n</pre>\r\n\r\nYou'll find the content on pre-commit.log on [pastebin](http://pastebin.com/Ls61EQDj).\r\n\r\nNow the if I comment out the install_scripts parameter, everything works fine\r\n\r\n<pre>\r\n$ cat setup.cfg \r\n[install]\r\n#install_scripts=/usr/sbin\r\n$ pre-commit clean\r\nCleaned /home/wilfried/.pre-commit.\r\n$ pre-commit run --all-files\r\n[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.\r\n[INFO] Once installed this environment will be reused.\r\n[INFO] This may take a few minutes...\r\nTrim Trailing Whitespace.............................(no files to check)Skipped\r\n</pre>\r\n\r\nI'm running on a linux mint 18, with python 2.7.12 and pre-commit 0.9.2\r\n<pre>\r\n$ python --version\r\nPython 2.7.12\r\n$ pre-commit --version\r\npre-commit 0.9.2\r\n</pre>\r\n\r\nLet my know if you need anything else.\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        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"}], "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, cwd='/')\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"}]}