idf_tools.py: fix virtualenv issue for macOS with homebrew

This commit is contained in:
Ivan Grokhotkov
2019-10-30 16:19:17 +01:00
parent 09dd8ca3e9
commit 5ab36dc2ec

View File

@@ -1344,6 +1344,11 @@ def main(argv):
global global_idf_tools_path
global_idf_tools_path = os.environ.get('IDF_TOOLS_PATH') or os.path.expanduser(IDF_TOOLS_PATH_DEFAULT)
# On macOS, unset __PYVENV_LAUNCHER__ variable if it is set.
# Otherwise sys.executable keeps pointing to the system Python, even when a python binary from a virtualenv is invoked.
# See https://bugs.python.org/issue22490#msg283859.
os.environ.pop('__PYVENV_LAUNCER__', None)
if sys.version_info.major == 2:
try:
global_idf_tools_path.decode('ascii')