The following revision refers to this bug:
https://chromium.googlesource.com/chromium/tools/build/+/bf2efddbc1f84363b8f9fdceb732d5b84cdb63be
commit bf2efddbc1f84363b8f9fdceb732d5b84cdb63be
Author: Robert Iannucci <iannucci@chromium.org>
Date: Thu Mar 22 22:16:25 2018
[common/env.py] Remove GetSysPythonPath and GetEnvPythonPath.
GetSysPythonPath is interfering with using vpython for sub-invocations
(and I believe it was actually never necessary and was added due to a
misunderstanding of how PYTHONPATH works).
PYTHONPATH is prefixed to the internal calculation of sys.path of
whatever python interpreter starts up. The interpreter takes PYTHONPATH
from the env, then adds in any libraries which are installed with that
interpreter.
When you're using system python for both runit and also the subprocess,
exporting sys.path to PYTHONPATH is redundant, but not harmful. e.g.
runit would export:
PYTHONPATH=/build.git:/sys_python
And then when the subpython starts up, it would calculate sys.path to be:
sys.path=/build.git:/sys_python:/sys_python
However, when you're using vpython to invoke runit and the subprocess
with two different virtualenvs, you get:
PYTHONPATH=/build.git:/vpython/deadbeef
sys.path=/build.git:/vpython/deadbeef:/vpython/feedface
Where 'feedface' is the environment that your script actually wants!
By removing GetSysPythonPath from the equation, we'll now do:
PYTHONPATH=/build.git
sys.path=/build.git:/vpython/feedface
Which should actually work correctly. I believe that GetSysPythonPath
was added under the assumption that python ONLY consults PYTHONPATH for
libraries when PYTHONPATH is set in the environment, and so we needed
to preserve the current sys.path entries for correct behavior.
GetEnvPythonPath seems to be entirely unused.
R=dnj@chromium.org, nodir@chromium.org, vadimsh@chromium.org, yyanagisawa@chromium.org
Bug: 776430,814607, 822103 ,822042
Change-Id: I8f6a724a6612b8837e0cd1b6fa8ad7a20e793efe
Reviewed-on: https://chromium-review.googlesource.com/974759
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: smut <smut@google.com>
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
[modify] https://crrev.com/bf2efddbc1f84363b8f9fdceb732d5b84cdb63be/scripts/common/env.py
[modify] https://crrev.com/bf2efddbc1f84363b8f9fdceb732d5b84cdb63be/scripts/common/unittests/env_test.py
Comment 1 by yyanagisawa@chromium.org
, Mar 15 2018Blocking: 776430