Clear out existing virtualenv when creating
We check whether a virtualenv has been created successfully by the
spec file that is written after the virtualenv has been initialized
and the spec requirements installed. In the event that a previous run
failed before the spec file was written, we want to clear out the
partially created virtualenv and recreate it fresh.
BUG=chromium:703769
TEST=virtualenv VM tests
Change-Id: I060f1fa54cea1ac6042a29215d67617ae563a487
Reviewed-on: https://chromium-review.googlesource.com/461229
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/cros_venv/venvlib.py b/cros_venv/venvlib.py
index 1991bc0..16524fd 100644
--- a/cros_venv/venvlib.py
+++ b/cros_venv/venvlib.py
@@ -277,7 +277,8 @@
# does not document it. Once we no longer have any hosts on
# virtualenv 1.7, the --setuptools option can be removed.
command = ['virtualenv', venvdir, '-p', _VENV_PY,
- '--extra-search-dir', _PACKAGE_DIR, '--setuptools']
+ '--extra-search-dir', _PACKAGE_DIR, '--setuptools',
+ '--clear']
_log_check_call(command, logfile=logfile)