Skip to content

Commit 0aed648

Browse files
committed
[Docs] Add Python caveats under the development section
This adds a page named Caveats with a section on some of the things to be aware of related to Python. It's a question we've seen more than once pop up and I think it's good to have it documentation on the website. Even though some of it might be useful to users, I still put it under "development" because it requires some understanding of how LLDB is built. Differential revision: https://reviews.llvm.org/D70252
1 parent 63f0f54 commit 0aed648

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

lldb/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ interesting areas to contribute to lldb.
144144
resources/test
145145
resources/bots
146146
resources/sbapi
147+
resources/caveats
147148

148149
.. toctree::
149150
:hidden:

lldb/docs/resources/build.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ built correctly and is available to the default Python interpreter, run:
533533

534534
> python -c 'import lldb'
535535

536+
537+
Make sure you're using the Python interpreter that matches the Python library
538+
you linked against. For more details please refer to the :ref:`caveats
539+
<python_caveat>`.
540+
536541
.. _CodeSigning:
537542

538543
Code Signing on macOS

lldb/docs/resources/caveats.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Caveats
2+
=======
3+
4+
.. contents::
5+
:local:
6+
7+
.. _python_caveat:
8+
9+
Python
10+
------
11+
12+
LLDB has a powerful scripting interface which is accessible through Python.
13+
Python is available either from withing LLDB through a (interactive) script
14+
interpreter, or as a Python module which you can import from the Python
15+
interpreter.
16+
17+
To make this possible, LLDB links against the Python shared library. Linking
18+
against Python comes with some constraints to be aware of.
19+
20+
1. It is not possible to build and link LLDB against a Python 3 library and
21+
use it from Python 2 and vice versa.
22+
23+
2. It is not possible to build and link LLDB against one distribution on
24+
Python and use it through a interpreter coming from another distribution.
25+
For example, on macOS, if you build and link against Python from
26+
python.org, you cannot import the lldb module from the Python interpreter
27+
installed with Homebrew.
28+
29+
3. To use third party Python packages from inside LLDB, you need to install
30+
them using a utility (such as ``pip``) from the same Python distribution as
31+
the one used to build and link LLDB.
32+
33+
The previous considerations are especially important during development, but
34+
apply to binary distributions of LLDB as well. For example, the LLDB that comes
35+
with Xcode links against the Python 3 that's part of Xcode. Therefore you
36+
should always use the Python in Xcode (through ``xcrun python3`` or
37+
``/usr/bin/python3``) to import the lldb module or install packages.

0 commit comments

Comments
 (0)