Repository: pre-commit/pre-commit
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.

Changed files:
tests/repository_test.py, pre_commit/languages/python.py

diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index 7eadb8d..d785bbc 100644
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -73,7 +73,7 @@ def install_environment(
             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,
diff --git a/tests/repository_test.py b/tests/repository_test.py
index 0ac2d47..7095bda 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -81,6 +81,20 @@ def test_python_hook_args_with_spaces(tempdir_factory, store):
     )
 
 
+@pytest.mark.integration
+def test_python_hook_weird_setup_cfg(tempdir_factory, store):
+    path = git_dir(tempdir_factory)
+    with cwd(path):
+        with io.open('setup.cfg', 'w') as setup_cfg:
+            setup_cfg.write('[install]\\ninstall_scripts=/usr/sbin\\n')
+
+        _test_hook_repo(
+            tempdir_factory, store, 'python_hooks_repo',
+            'foo', [os.devnull],
+            b"['" + five.to_bytes(os.devnull) + b"']\\nHello World\\n"
+        )
+
+
 @pytest.mark.integration
 def test_switch_language_versions_doesnt_clobber(tempdir_factory, store):
     # We're using the python3 repo because it prints the python version