Skip to content

Commit b7eb820

Browse files
committed
Don't import cppyy before ROOT in cmdLineUtils
If you import `cppyy` before ROOT, you get these warnings by default: ```txt /home/rembserj/code/root/root_install/lib/root/cppyy_backend/loader.py:147: UserWarning: No precompiled header available (cannot import name 'get_cppversion' from 'cppyy_backend._get_cppflags' (/home/rembserj/code/root/root_install/lib/root/cppyy_backend/_get_cppflags.py)); this may impact performance. warnings.warn('No precompiled header available (%s); this may impact performance.' % msg) /home/rembserj/code/root/root_install/lib/root/cppyy/__init__.py:378: UserWarning: CPyCppyy API not found (tried: /nix/store/8w718rm43x7z73xhw9d6vh8s4snrq67h-python3-3.12.10/include/site/python3.12); set CPPYY_API_PATH envar to the 'CPyCppyy' API directory to fix warnings.warn("CPyCppyy API not found (tried: %s); " ``` Doing the import locally, so it happens after `import ROOT`, avoids these warnings.
1 parent 0d868ef commit b7eb820

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main/python/cmdLineUtils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import sys
1919
from time import sleep
2020
from itertools import zip_longest
21-
import cppyy
2221

2322
def fileno(file_or_fd):
2423
"""
@@ -196,6 +195,8 @@ def isDirectoryKey(key):
196195
"""
197196
Return True if the object, corresponding to the key, inherits from TDirectory
198197
"""
198+
import cppyy
199+
199200
classname = key.GetClassName()
200201
cl = ROOT.gROOT.GetClass(classname)
201202
if cl == cppyy.nullptr:
@@ -208,6 +209,8 @@ def isTreeKey(key):
208209
"""
209210
Return True if the object, corresponding to the key, inherits from TTree
210211
"""
212+
import cppyy
213+
211214
classname = key.GetClassName()
212215
cl = ROOT.gROOT.GetClass(classname)
213216
if cl == cppyy.nullptr:
@@ -220,6 +223,8 @@ def isTHnSparseKey(key):
220223
"""
221224
Return True if the object, corresponding to the key, inherits from THnSparse
222225
"""
226+
import cppyy
227+
223228
classname = key.GetClassName()
224229
cl = ROOT.gROOT.GetClass(classname)
225230
if cl == cppyy.nullptr:

0 commit comments

Comments
 (0)