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

feat: support for python (import edm4eic) #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ list(APPEND EDM4EIC_INSTALL_LIBS edm4eic edm4eicDict)

add_subdirectory(utils)
add_subdirectory(test)
add_subdirectory(python)

install(TARGETS ${EDM4EIC_INSTALL_LIBS}
EXPORT ${PROJECT_NAME}Targets
Expand Down
6 changes: 6 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

install(DIRECTORY edm4eic DESTINATION python
REGEX .*\\.in EXCLUDE
PATTERN __pycache__ EXCLUDE
)
29 changes: 29 additions & 0 deletions python/edm4eic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SPDX-License-Identifier: Apache-2.0

"""Python module for the EDM4EIC datamodel and utilities."""
import sys

from .__version__ import __version__
import ROOT
res = ROOT.gSystem.Load('libedm4eicDict.so')
if res < 0:
raise RuntimeError('Failed to load libedm4eicDict.so')

res = ROOT.gSystem.Load('libedm4eicRDF.so')
if res < 0:
raise RuntimeError('Failed to load libedm4eicRDF.so')

res = ROOT.gInterpreter.LoadFile('edm4eic/utils/kinematics.h')
if res != 0:
raise RuntimeError('Failed to load kinematics.h')

res = ROOT.gInterpreter.LoadFile('edm4eic/utils/dataframe.h')
if res != 0:
raise RuntimeError('Failed to load dataframe.h')
from ROOT import edm4eic

# Make TAB completion work for utils
setattr(edm4eic, 'utils', edm4eic.utils)

# Make `import edm4eic` work
sys.modules['edm4eic'] = edm4eic
3 changes: 3 additions & 0 deletions python/edm4eic/__version__.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

__version__ = "@EDM4EIC_VERSION@"