mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
parent
1dbcfe3adb
commit
d58b945107
1 changed files with 12 additions and 5 deletions
|
|
@ -5,8 +5,6 @@ import distutils.spawn
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import virtualenv
|
|
||||||
|
|
||||||
from pre_commit.languages import helpers
|
from pre_commit.languages import helpers
|
||||||
from pre_commit.util import clean_path_on_failure
|
from pre_commit.util import clean_path_on_failure
|
||||||
from pre_commit.util import shell_escape
|
from pre_commit.util import shell_escape
|
||||||
|
|
@ -15,13 +13,22 @@ from pre_commit.util import shell_escape
|
||||||
ENVIRONMENT_DIR = 'py_env'
|
ENVIRONMENT_DIR = 'py_env'
|
||||||
|
|
||||||
|
|
||||||
|
def bin_dir(venv):
|
||||||
|
"""On windows there's a different directory for the virtualenv"""
|
||||||
|
if os.name == 'nt': # pragma: no cover (windows)
|
||||||
|
return os.path.join(venv, 'Scripts')
|
||||||
|
else:
|
||||||
|
return os.path.join(venv, 'bin')
|
||||||
|
|
||||||
|
|
||||||
class PythonEnv(helpers.Environment):
|
class PythonEnv(helpers.Environment):
|
||||||
@property
|
@property
|
||||||
def env_prefix(self):
|
def env_prefix(self):
|
||||||
return ". '{{prefix}}{0}activate' &&".format(
|
return ". '{{prefix}}{0}{1}activate' &&".format(
|
||||||
virtualenv.path_locations(
|
bin_dir(
|
||||||
helpers.environment_dir(ENVIRONMENT_DIR, self.language_version)
|
helpers.environment_dir(ENVIRONMENT_DIR, self.language_version)
|
||||||
)[-1].rstrip(os.sep) + os.sep,
|
),
|
||||||
|
os.sep,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue