Skip to content

Commit 0eaacd7

Browse files
committed
Default to python3 when using python_venv under python 2
1 parent df1b720 commit 0eaacd7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pre_commit/languages/python_venv.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import unicode_literals
22

33
import os.path
4+
import sys
45

56
from pre_commit.languages import python
67
from pre_commit.util import CalledProcessError
@@ -10,6 +11,13 @@
1011
ENVIRONMENT_DIR = 'py_venv'
1112

1213

14+
def get_default_version(): # pragma: no cover (version specific)
15+
if sys.version_info < (3,):
16+
return 'python3'
17+
else:
18+
return python.get_default_version()
19+
20+
1321
def orig_py_exe(exe): # pragma: no cover (platform specific)
1422
"""A -mvenv virtualenv made from a -mvirtualenv virtualenv installs
1523
packages to the incorrect location. Attempt to find the _original_ exe
@@ -43,6 +51,5 @@ def make_venv(envdir, python):
4351
cmd_output(orig_py_exe(python), '-mvenv', envdir, cwd='/')
4452

4553

46-
get_default_version = python.get_default_version
4754
_interface = python.py_interface(ENVIRONMENT_DIR, make_venv)
4855
in_env, healthy, run_hook, install_environment = _interface

0 commit comments

Comments
 (0)