brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · a3dcf24 Raw
69 lines · plain
1Caveats2=======3 4.. _python_caveat:5 6Python7------8 9LLDB has a powerful scripting interface which is accessible through Python.10Python is available either from within LLDB through a (interactive) script11interpreter, or as a Python module which you can import from the Python12interpreter.13 14To make this possible, LLDB links against the Python shared library. Linking15against Python comes with some constraints to be aware of.16 171.  It is not possible to build and link LLDB against a Python 3 library and18    use it from Python 2 and vice versa.19 202.  It is not possible to build and link LLDB against one distribution on21    Python and use it through an interpreter coming from another distribution.22    For example, on macOS, if you build and link against Python from23    python.org, you cannot import the lldb module from the Python interpreter24    installed with Homebrew.25 263.  To use third party Python packages from inside LLDB, you need to install27    them using a utility (such as ``pip``) from the same Python distribution as28    the one used to build and link LLDB.29 30The previous considerations are especially important during development, but31apply to binary distributions of LLDB as well.32 33LLDB in Xcode on macOS34``````````````````````35 36Users of lldb in Xcode on macOS commonly run into these issues when they37install Python, often unknowingly as a dependency pulled in by Homebrew or38other package managers. The problem is the symlinks that get created in39``/usr/local/bin``, which comes before ``/usr/bin`` in your path. You can use40``which python3`` to check to what it resolves.41 42To be sure you use the Python that matches with the lldb in Xcode use ``xcrun``43or use the absolute path to the shims in ``/usr/bin``.44 45::46 47   $ xcrun python348   $ /usr/bin/python349 50Similarly, to install packages and be able to use them from within lldb, you'll51need to install them with the matching ``pip3``.52 53::54 55   $ xcrun pip356   $ /usr/bin/pip357 58The same is true for Python 2. Although Python 2 comes with the operating59system rather than Xcode, you can still use ``xcrun`` to launch the system60variant.61 62::63 64   $ xcrun python65   $ /usr/bin/python66 67Keep in mind that Python 2 is deprecated and no longer maintained. Future68versions of macOS will not include Python 2.7.69