Skip to content

Commit 0041582

Browse files
committed
[lldb] Fix Python interpreter workaround (attempt #2)
On macOS, to make DYLD_INSERT_LIBRARIES and the Python shim work together, we have a workaroud that copies the "real" Python interpreter into the build directory. This doesn't work when running in a virtual environment, as the copied interpreter cannot find the packages installed in the virtual environment relative to itself. Address this issue by copying the Python interpreter into the virtual environment's `bin` folder, rather than the build folder, when the test suite detects that it's being run inside a virtual environment. I'm not thrilled about this solution because it puts a file outside the build directory. However, given virtual environments are considered disposable, this seems reasonable.
1 parent 68fc8df commit 0041582

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lldb/test/API/lit.cfg.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ def find_python_interpreter():
6363
if "DYLD_INSERT_LIBRARIES" not in config.environment:
6464
return None
6565

66-
# If we're running in a virtual environment, we already have a copy of the
67-
# Python executable.
66+
# If we're running in a virtual environment, we have to copy Python into
67+
# the virtual environment for it to work.
6868
if sys.prefix != sys.base_prefix:
69-
return None
69+
copied_python = os.path.join(sys.prefix, "bin", "copied-python")
70+
else:
71+
copied_python = os.path.join(config.lldb_build_directory, "copied-python")
7072

7173
# Avoid doing any work if we already copied the binary.
72-
copied_python = os.path.join(config.lldb_build_directory, "copied-python")
7374
if os.path.isfile(copied_python):
7475
return copied_python
7576

0 commit comments

Comments
 (0)