Usage in Python

HepLib provides a wrapper class HepLibW as an interface to other languages, the SWIG interace file HepLib.i is also installed <INSTALL_PATH>/include/HepLib.i. We will just show the usage within python, but it also applys to other languages with the help of SWIG.

Compile the python module

One can use the following makefile to generate the python module files: _HepLib.so and HepLib.py.

all: _HepLib.so
HLS=HepLib_SWIG
flatns=""

uname := $(shell uname -s)
ifeq ($(uname),Darwin)
  flatns = "-flat_namespace"
endif

$(HLS).cpp:
        swig -python -c++ -o $(HLS).cpp $$(heplib-config --prefix)/include/HepLib.i
$(HLS).o : $(HLS).cpp
        heplib++ -fPIC -c $(HLS).cpp $$(python3-config --cflags)
_HepLib.so : $(HLS).o
        heplib++ -shared $(flatns) $(HLS).o -o _HepLib.so $$(python3-config --ldflags --embed)
clean:
        rm -f $(HLS)* _HepLib.so HepLib.py

Python version for various C++ codes

Note: the various .cpp files are introduced in Reference: https://doi.org/10.1016/j.cpc.2021.107982

  • 0.py (python version for 0.cpp)

  • 1.py (python version for 1.cpp)

  • 2.py (python version for2.cpp)

  • 3.py (python version for3.cpp)

  • 4.py (python version for4.cpp)

  • 5.py (python version for5.cpp)

  • 6.py (python version for6.cpp)

  • 7.py (python version for7.cpp)

  • 8.py (python version for8.cpp)

  • 9.py (python version for9.cpp)

Last updated