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