From 4b98b39cea3c4afc103bf477c2f8b42e9dd1aaf6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 2 Jun 2014 07:26:44 -0700 Subject: [PATCH] language_version works for python. --- pre_commit/languages/python.py | 5 ++++- setup.py | 1 + tests/repository_test.py | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py index 68a38887..0ad39c0a 100644 --- a/pre_commit/languages/python.py +++ b/pre_commit/languages/python.py @@ -23,7 +23,10 @@ def install_environment(repo_cmd_runner, version='default'): # Install a virtualenv with clean_path_on_failure(repo_cmd_runner.path(ENVIRONMENT_DIR)): - repo_cmd_runner.run(['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)]) + venv_cmd = ['virtualenv', '{{prefix}}{0}'.format(ENVIRONMENT_DIR)] + if version != 'default': + venv_cmd.extend(['-p', version]) + repo_cmd_runner.run(venv_cmd) with in_env(repo_cmd_runner) as env: env.run('cd {prefix} && pip install .') diff --git a/setup.py b/setup.py index 3a5a857b..2417b1ae 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ setup( 'plumbum', 'pyyaml', 'simplejson', + 'virtualenv', ], entry_points={ 'console_scripts': [ diff --git a/tests/repository_test.py b/tests/repository_test.py index 8beaeff5..408eb8f8 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -24,7 +24,6 @@ def test_run_a_python_hook(config_for_python_hooks_repo, store): assert ret[1] == "['/dev/null']\nHello World\n" -@pytest.mark.xfail @pytest.mark.integration def test_run_versioned_hook(config_for_python3_hooks_repo, store): repo = Repository.create(config_for_python3_hooks_repo, store)