1- @page python_bindings Python Bindings for Examples
1+ @defgroup python_bindings Python Bindings
2+ @brief Python bindings for the ACTS tracking toolkit, available via PyPI or built from source.
23
3- The examples part of ACTS ships with python bindings using the ` pybind11 `
4- library. Building these bindings can be enabled via
5- ` -DACTS_BUILD_EXAMPLES_PYTHON_BINDINGS=ON ` , and requires a python installation
6- including the development files to be installed. You can then build the special
7- target ` ActsPythonBindings ` to build everything that can be accessed in python.
4+ # Installation from PyPI
85
9- The build will create a setup script in ` $BUILD/this_acts_withdeps.sh ` which
10- modifies ` $PYTHONPATH ` so that you can import the ` acts ` module in python.
6+ The easiest way to get the ACTS Python bindings is via [ PyPI] ( https://pypi.org/project/pyacts/ ) :
117
12- Here is a minimal example of a python script using the example bindings, which
13- sets up the particle propagation and runs a few events.
8+ ``` console
9+ pip install pyacts
10+ ```
11+
12+ A nightly development build is also available from [ TestPyPI] ( https://test.pypi.org/project/pyacts/ ) :
13+
14+ ``` console
15+ pip install -i https://test.pypi.org/simple pyacts
16+ ```
17+
18+ The ` pyacts ` distribution includes bindings for the core library, Fatras, and
19+ the Examples framework.
20+
21+ > [ !warning]
22+ > The PyPI package does not include all optional plugins (e.g. DD4hep/ODD, Geant4, ROOT).
23+ > To use those, build from source with the relevant CMake options enabled.
24+
25+ > [ !note]
26+ > Even though the name of the PyPI package is ` pyacts ` , the python module must be imported
27+ > as ` import acts ` .
28+
29+ # Building from source
30+
31+ To use the full Python bindings including optional components such as DD4hep/ODD, Geant4, ROOT, build ACTS from
32+ source with ` ACTS_BUILD_PYTHON_BINDINGS=ON ` .
33+
34+ ``` console
35+ cmake -B <build> -S <source> -DACTS_BUILD_PYTHON_BINDINGS=ON
36+ ```
37+
38+ Bindings for additional components (plugins, Examples framework) are built automatically if
39+ they are enabled.
40+
41+ ``` console
42+ cmake -B <build> -S <source> -DACTS_BUILD_PYTHON_BINDINGS=ON -DACTS_BUILD_EXAMPLES=ON
43+ ```
44+
45+ Building requires a Python installation including the development headers.
46+ You can then build the special target ` ActsPythonBindings ` to build everything
47+ that can be accessed from Python:
48+
49+ ``` console
50+ cmake --build <build> -- ActsPythonBindings
51+ ```
52+
53+ The build creates a setup script ` $BUILD/this_acts_withdeps.sh ` which modifies
54+ ` $PYTHONPATH ` so that you can import the ` acts ` module in Python.
55+
56+ > [ !warning]
57+ > The old flag ` ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS ` is ** deprecated** .
58+ > Use ` ACTS_BUILD_PYTHON_BINDINGS ` (together with ` ACTS_BUILD_EXAMPLES ` if
59+ > needed) instead.
60+
61+ # Minimal example
62+
63+ Here is a minimal example of a Python script using the bindings, which sets up
64+ particle propagation and runs a few events.
1465
1566@snippet {trimleft} examples/test_generic.py Basic propagation example with GenericDetector
1667
@@ -23,16 +74,16 @@ They can be found in `$REPO_ROOT/Examples/Scripts/Python`. Make sure you have ru
2374source $BUILD/this_acts_withdeps.sh
2475```
2576
26- to make sure python can find the ` acts ` module.
77+ to make sure Python can find the ` acts ` module.
2778
2879## Python based unit tests
2980
3081A number of unit tests based on the ` pytest ` library are shipped with the
3182repository. They are located under ` $REPO_ROOT/Examples/Python/tests ` , and
32- intend to cover the public API of the python bindings. A set of tests also
33- executed the standalone example scripts.
83+ intend to cover the public API of the Python bindings. A set of tests also
84+ execute the standalone example scripts.
3485
35- To run these python based tests, ` pytest ` and a few other dependencies need
86+ To run these Python based tests, ` pytest ` and a few other dependencies need
3687to be installed. They can be installed via `pip install -r
3788Examples/Python/tests/requirements.txt` from the repository root. You can
3889then simply run ` pytest ` from the repository root.
0 commit comments