Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python imports when built without SIO support #490

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else()
DESTINATION ${podio_PYTHON_INSTALLDIR}
REGEX test_.*\\.py$ EXCLUDE # Do not install test files
PATTERN __pycache__ EXCLUDE # Or pythons caches
REGEX .*sio.*\\.py$ EXCLUDE # All things sio related
REGEX .*sio_.*\\.py$ EXCLUDE # All things sio related
)
endif()

Expand Down
10 changes: 9 additions & 1 deletion python/podio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@

if _DYNAMIC_LIBS_LOADED:
from .frame import Frame
from . import root_io, sio_io, reading
from . import root_io, reading

try:
# We try to import the sio bindings which may fail if ROOT is not able to
# load the dictionary in this case they have most likely not been built and
# we just move on
from . import sio_io
except ImportError:
pass

from . import EventStore

Expand Down
3 changes: 2 additions & 1 deletion python/podio/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import os
import ROOT

ROOT.gSystem.Load("libTestDataModelDict.so") # noqa: E402
if ROOT.gSystem.DynamicPathName("libTestDataModelDict.so", True): # noqa: E402
ROOT.gSystem.Load("libTestDataModelDict.so") # noqa: E402
from ROOT import ExampleHitCollection, ExampleClusterCollection # noqa: E402 # pylint: disable=wrong-import-position

from podio import Frame # pylint: disable=wrong-import-position
Expand Down