xref: /aosp_15_r20/external/llvm/bindings/python/README.txt (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard WorkerThis directory contains Python bindings for LLVM's C library.
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard WorkerThe bindings are currently a work in progress and are far from complete.
4*9880d681SAndroid Build Coastguard WorkerUse at your own risk.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard WorkerDeveloper Info
7*9880d681SAndroid Build Coastguard Worker==============
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard WorkerThe single Python package is "llvm." Modules inside this package roughly
10*9880d681SAndroid Build Coastguard Workerfollow the names of the modules/headers defined by LLVM's C API.
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard WorkerTesting
13*9880d681SAndroid Build Coastguard Worker-------
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard WorkerAll test code is location in llvm/tests. Tests are written as classes
16*9880d681SAndroid Build Coastguard Workerwhich inherit from llvm.tests.base.TestBase, which is a convenience base
17*9880d681SAndroid Build Coastguard Workerclass that provides common functionality.
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard WorkerTests can be executed by installing nose:
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker    pip install nosetests
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard WorkerThen by running nosetests:
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker    nosetests
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard WorkerTo see more output:
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker    nosetests -v
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard WorkerTo step into the Python debugger while running a test, add the following
32*9880d681SAndroid Build Coastguard Workerto your test at the point you wish to enter the debugger:
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker    import pdb; pdb.set_trace()
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard WorkerThen run nosetests:
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker    nosetests -s -v
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard WorkerYou should strive for high code coverage. To see current coverage:
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker    pip install coverage
43*9880d681SAndroid Build Coastguard Worker    nosetests --with-coverage --cover-html
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard WorkerThen open cover/index.html in your browser of choice to see the code coverage.
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard WorkerStyle Convention
48*9880d681SAndroid Build Coastguard Worker----------------
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard WorkerAll code should pass PyFlakes. First, install PyFlakes:
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker    pip install pyflakes
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard WorkerThen at any time run it to see a report:
55*9880d681SAndroid Build Coastguard Worker
56*9880d681SAndroid Build Coastguard Worker    pyflakes .
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard WorkerEventually we'll provide a Pylint config file. In the meantime, install
59*9880d681SAndroid Build Coastguard WorkerPylint:
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker    pip install pylint
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard WorkerAnd run:
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Worker    pylint llvm
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard WorkerAnd try to keep the number of violations to a minimum.
68