mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #797 from pre-commit/default_python_3_venv
Default to python3 when using python_venv under python 2
This commit is contained in:
commit
99972df1da
1 changed files with 8 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
from pre_commit.languages import python
|
from pre_commit.languages import python
|
||||||
from pre_commit.util import CalledProcessError
|
from pre_commit.util import CalledProcessError
|
||||||
|
|
@ -10,6 +11,13 @@ from pre_commit.util import cmd_output
|
||||||
ENVIRONMENT_DIR = 'py_venv'
|
ENVIRONMENT_DIR = 'py_venv'
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_version(): # pragma: no cover (version specific)
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
return 'python3'
|
||||||
|
else:
|
||||||
|
return python.get_default_version()
|
||||||
|
|
||||||
|
|
||||||
def orig_py_exe(exe): # pragma: no cover (platform specific)
|
def orig_py_exe(exe): # pragma: no cover (platform specific)
|
||||||
"""A -mvenv virtualenv made from a -mvirtualenv virtualenv installs
|
"""A -mvenv virtualenv made from a -mvirtualenv virtualenv installs
|
||||||
packages to the incorrect location. Attempt to find the _original_ exe
|
packages to the incorrect location. Attempt to find the _original_ exe
|
||||||
|
|
@ -43,6 +51,5 @@ def make_venv(envdir, python):
|
||||||
cmd_output(orig_py_exe(python), '-mvenv', envdir, cwd='/')
|
cmd_output(orig_py_exe(python), '-mvenv', envdir, cwd='/')
|
||||||
|
|
||||||
|
|
||||||
get_default_version = python.get_default_version
|
|
||||||
_interface = python.py_interface(ENVIRONMENT_DIR, make_venv)
|
_interface = python.py_interface(ENVIRONMENT_DIR, make_venv)
|
||||||
in_env, healthy, run_hook, install_environment = _interface
|
in_env, healthy, run_hook, install_environment = _interface
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue