Python Bindings Plug-In

This plug-in implements libFAUDES bindings for the scripting language Python. Relevant libFAUDES data types and functions as documented via the libFAUDES User Reference can be accessed from within the Python interpreter. For user documentation/introduction specifically for the faudes Python module, see the libFAUDES Python API.

The most convenient method to make the faudes Python module available is to install it via pip; i.e., for Linux and macOS

$ pip install faudes
$ python3 -c "import faudes; print(faudes.Version())"

or, for native Windows

> py -m pip install faudes
> py -c "import faudes; print(faudes.Version())"

This will search the index PyPI for a binary distribution that fits your platform/archirectur. In the case no such matching binary is present, please let us know. Instructions on how to compile your own binary are below.

Example Script

# load libFAUDES bindings
from faudes import *
# test
Version()
Build()
# instantiate generator from Python lists
g = Generator.NewFromLists(
delta=[
['idle', 'alpha', 'busy'],
['busy', 'beta', 'idle']],
Q0 =[ 'idle' ],
Qm =[ 'idle' ]
)
# show on console
g.Write()
# show graphically, i.e., in Jupyter notebook
g.GraphShow()

Note: for graphics output you must have installed dot from the GraphViz package. If dot is not in the systems path, you may direct libfaudes via

DocExecPath("/wherever_dot_is/dot").

Building the libFAUDES Python module

The faudes Python module consists of the glue code faudes.py and a suitably extended libFAUDES shrared object _faudes.so (or _faudes.pyd for Windows). Both files are generated by the libFAUDES build system; see build-system documentation for details. Manualy copying/renaming both files to a project folder enables the import of the faudes module from Python scripts in that folder.

Example for the overall build process incl. copy/rename:

./libFAUDES$ make dist-clean
./libFAUDES$ make -j configure
./libFAUDES$ make -j
./libFAUDES$ cp plugings/pybindings/obj/faudes.py whereever/
./libFAUDES$ cp plugings/pybindings/obj/_faudes.so whereever/
./libFAUDES$ cd whereever
./whereever$ python3 -c "import faudes; print(faudes.Version())"

The above method is specifically recommended for MSYS environments where pip install from PyPI.org will fail.

Building the libFAUDES Python module

A Python wheel is an archive in a clearly defined format/layout which among others facilitates binary distribution of Python extenstions e.g. via PyPI.org. The libFAUDES build system has a dedicated target pybindings-wheel that utilises the Python module build to generate a Python wheel faudes-*.whl. The latter can be installed via pip. The benefit of this approach is that Python build takes care of matching toolchains etc. and that after installing the the module files do not need to be copied to each relevant project folder. The downside is that Python build wont use parallel jobs and therefore can take quite some time.

Example for the overall build process incl. installation:

./libFAUDES$ make dist-clean
./libFAUDES$ make -j configure
./libFAUDES$ make pybindings-wheel
./libFAUDES$ pip install faudes-2.34.0-cp314-cp314-macosx_10_15_universal2.whl

Alternatively, you may download the configured source from PyPI and invoke build directly; e.g. for Windows with official Python distribution and MSVC installed

./faudes-2.34> py -m build --wheel --outdir=./

License

The Python bindings plug-in is distributed with libFAUDES. All code is provided under terms of the LGPL.

Copyright (c) 2023 - 2026 Thomas Moor.

libFAUDES 2.34g --- 2026.03.30 --- c++ api documentaion by doxygen