We have a lot of Python code in test and scripts that in theory could be reused amongst the two. Until now there is no mechanism to support this because Python's module / packaging system imposes some limitations on how and where your code must be in order to be re-used.
This patch addresses this by creating a new module lldb_shared which searches up the tree until it finds an lldb.root file. Then, it dynamically imports lldb_shared_base from that folder. lldb_shared_base is a module that exists only as a means to modify sys.path to add all of the shared module locations ot the path.
In order to make use of this, you need to copy the lldb_shared.py file into the root of each project that you wish to make use of this shared code.
The end result of this is that if you have a directory structure like this:
lldb \__ test \__ scripts \__ common \__ useful_utility.py \__ third_party \__ six \__ six.py
All you need to do is add lldb_shared.py to the root of lldb/test and lldb/scripts and then you can write
import lldb_shared import useful_utility import six
This patch is dependent on D13880