mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Attempt with subprocess instead
This commit is contained in:
parent
4db38596c8
commit
0f14d4c072
1 changed files with 13 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
from plumbum import local
|
from plumbum import local
|
||||||
|
import subprocess
|
||||||
|
|
||||||
PY_ENV = 'py_env'
|
PY_ENV = 'py_env'
|
||||||
|
|
||||||
|
|
@ -7,7 +8,7 @@ PY_ENV = 'py_env'
|
||||||
def install_environment():
|
def install_environment():
|
||||||
assert local.path('setup.py').exists()
|
assert local.path('setup.py').exists()
|
||||||
# Return immediately if we already have a virtualenv
|
# Return immediately if we already have a virtualenv
|
||||||
if local.path('py_env').exists():
|
if local.path(PY_ENV).exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Install a virtualenv
|
# Install a virtualenv
|
||||||
|
|
@ -17,6 +18,17 @@ def install_environment():
|
||||||
|
|
||||||
def run_hook(hook, file_args):
|
def run_hook(hook, file_args):
|
||||||
# TODO: batch filenames
|
# TODO: batch filenames
|
||||||
|
process = subprocess.Popen(
|
||||||
|
['bash', '-c', ' '.join(
|
||||||
|
['source {0}/bin/activate &&'.format(PY_ENV)] +
|
||||||
|
[hook['entry']] + hook.get('args', []) + list(file_args)
|
||||||
|
)],
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
ret = process.communicate()
|
||||||
|
|
||||||
|
return (0,) + ret
|
||||||
|
|
||||||
return local['bash'][
|
return local['bash'][
|
||||||
'-c', ' '.join(
|
'-c', ' '.join(
|
||||||
['source {0}/bin/activate &&'.format(PY_ENV)] +
|
['source {0}/bin/activate &&'.format(PY_ENV)] +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue