From 9279b72a6cd04ef0cf1ac4d1cfaf416966ded7e3 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 30 Oct 2019 16:19:17 +0100 Subject: [PATCH] idf_tools.py: fix virtualenv issue for macOS with homebrew --- tools/idf_tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/idf_tools.py b/tools/idf_tools.py index a04cc1c9c..e9978ec60 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -1315,6 +1315,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')