mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-07 00:39:09 -06:00
Attempt with subprocess instead
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
from plumbum import local
|
||||
import subprocess
|
||||
|
||||
PY_ENV = 'py_env'
|
||||
|
||||
@@ -7,7 +8,7 @@ PY_ENV = 'py_env'
|
||||
def install_environment():
|
||||
assert local.path('setup.py').exists()
|
||||
# Return immediately if we already have a virtualenv
|
||||
if local.path('py_env').exists():
|
||||
if local.path(PY_ENV).exists():
|
||||
return
|
||||
|
||||
# Install a virtualenv
|
||||
@@ -17,6 +18,17 @@ def install_environment():
|
||||
|
||||
def run_hook(hook, file_args):
|
||||
# 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'][
|
||||
'-c', ' '.join(
|
||||
['source {0}/bin/activate &&'.format(PY_ENV)] +
|
||||
|
||||
Reference in New Issue
Block a user