diff --git a/build.py b/build.py index 71c505256..01e20546b 100644 --- a/build.py +++ b/build.py @@ -13,10 +13,6 @@ # See https://github.com/AspenWeb/pando.py/issues/542 USE_PY_VENV = sys.version_info > (3, 3) -ENV_ARGS = [ - '-m', ('venv' if USE_PY_VENV else 'virtualenv') -] - def _virt(cmd, envdir='env'): envdir = _env(envdir) @@ -52,8 +48,17 @@ def __env(envdir): # We've already built our own virtualenv. return envdir - args = [sys.executable] + ENV_ARGS + [envdir] - run(*args) + if USE_PY_VENV: + # use built-in venv module + run(sys.executable, '-m', 'venv', envdir) + else: + # use virtualenv instead + try: + import virtualenv + except ImportError: + # install it when missing + run(sys.executable, '-m', 'pip', 'install', '--user', 'virtualenv') + run(sys.executable, '-m', 'virtualenv', envdir) return envdir