venvlib: select the active python interp directly
We've been assuming the python version can be found under /usr/bin/.
This doesn't work when we're run via depot_tools python3 that is not
installed in /usr/bin/ at all, and a newer version that whatever is
there. Use sys.executable instead to get the full path to the active
Python interpreter.
BUG=chromium:997354
TEST=CQ passes
TEST=running on release configs works
Change-Id: I55e3efebb6daaa0b118d2b3af3f1e2dfc599652b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra_virtualenv/+/2136295
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/venv/cros_venv/venvlib.py b/venv/cros_venv/venvlib.py
index a8034c3..ec3a8d6 100644
--- a/venv/cros_venv/venvlib.py
+++ b/venv/cros_venv/venvlib.py
@@ -27,8 +27,6 @@
from cros_venv import flock
_PACKAGE_DIR = os.path.join(constants.REPO_DIR, 'pip_packages')
-_VENV_PY = ('/usr/bin/python%s.%s' %
- (sys.version_info.major, sys.version_info.minor))
_VIRTUALENV_COMMAND = 'virtualenv'
# BASE_DEPENDENCIES are pip requirements automatically included in every
@@ -235,7 +233,7 @@
# by default. virtualenv >1.10 accepts the --setuptools option but
# does not document it. Once we no longer have any hosts on
# virtualenv 1.7, the --setuptools option can be removed.
- command = [_VIRTUALENV_COMMAND, venvdir, '-p', _VENV_PY,
+ command = [_VIRTUALENV_COMMAND, venvdir, '-p', sys.executable,
'--extra-search-dir', _PACKAGE_DIR, '--setuptools',
'--clear']
try: