Skip to content

Commit

Permalink
Make Frame python bindings more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Sep 15, 2023
1 parent 096d494 commit 0c39a57
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/podio/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
import cppyy

import ROOT

# NOTE: It is necessary that this can be found on the ROOT_INCLUDE_PATH
ROOT.gInterpreter.LoadFile('podio/Frame.h') # noqa: E402
from ROOT import podio # noqa: E402 # pylint: disable=wrong-import-position
#
# We check whether we can actually load the header to not break python bindings
# in environments with *ancient* podio versions
if ROOT.gInterpreter.LoadFile('podio/Frame.h'): # noqa: E402
from ROOT import podio # noqa: E402 # pylint: disable=wrong-import-position
_FRAME_HEADER_AVAILABLE = True
else:
_FRAME_HEADER_AVAILABLE = False


def _determine_supported_parameter_types():
Expand Down Expand Up @@ -45,7 +52,8 @@ def _determine_cpp_type(idx_and_type):
return tuple(zip(cpp_types, py_types))


SUPPORTED_PARAMETER_TYPES = _determine_supported_parameter_types()
if _FRAME_HEADER_AVAILABLE:
SUPPORTED_PARAMETER_TYPES = _determine_supported_parameter_types()


def _get_cpp_types(type_str):
Expand Down

0 comments on commit 0c39a57

Please sign in to comment.