From 0f14d4c0726cac062719f6c2f0e46745477f4dfa Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 14 Mar 2014 00:04:15 -0700 Subject: [PATCH] Attempt with subprocess instead --- pre_commit/languages/python.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py index c2d49cf9..3c8f8f01 100644 --- a/pre_commit/languages/python.py +++ b/pre_commit/languages/python.py @@ -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)] +