Dear (py)ROOTers,
I have a code built on ROOT, let us call it MyPackage
, that I would like to wrap in a python module, let us call it mypackage
.
This topic
was very useful in importing the ROOT classes of the aforementioned code in a simple python script (even in a python jupyter notebook actually!).
Iβd like to go beyond that and build a python interface to the code, such that a user can install the python module and use the underlying ROOT classes from python.
Fundamentally I do not want a user to do the gSystem/gInterpreter
loading and then
from ROOT import MyPackageClass
Iβd like him to be able to directly do
from mypackage import mypackageclass
What would be the proper way of doing it?
From my limited experience I can only think to create a series of python modules, each wrapping the corresponding classes in MyPackage/include/
and then gather all of them in a module with __init__.py
. Schematically:
.
βββ include
β βββ FirstClass.h
β βββ SecondClass.h
β βββ ThirdClass.h
βββ wrapper
βββ __init__.py
βββ firstclass.py
βββ secondclass.py
βββ thirdclass.py
Additionally I do not know to which level Iβd have to expose the class.
Is there a cleaner and more and efficient way to realise it?
Has somebody already done it and has suggestion?
Thanks for your guidance.