-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PyROOT] Don't add gROOT and other globals manually to PyROOT via C++ #16869
Conversation
1fcaf05
to
cdcdc53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thanks! One small comment from my side
@@ -176,6 +176,8 @@ def find_spec(self, fullname: str, path, target=None) -> ModuleSpec: | |||
# Register cleanup | |||
import atexit | |||
|
|||
# Private handle to gROOT for later cleanup | |||
_gROOTForCleanup = cppyy.gbl.ROOT.GetROOT() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we initialize the variable directly within the cleanup
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I will check if this is possible once the CI is green in a first pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized we can get this directly from the facade, which also has it.
167ea46
to
292d8b1
Compare
bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tmva/__init__.py
Show resolved
Hide resolved
e86ffd9
to
6973248
Compare
Test Results 20 files 20 suites 4d 5h 19m 13s ⏱️ For more details on these failures, see this check. Results for commit 6aef770. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! But let's wait for the CI to be fully green, and also it would be nice to make clang-format happy
3692826
to
6aef770
Compare
This is not necessary if we consider that `gROOT` is actually a preprocessor macro that aliases to `ROOT::GetROOT()`, which we can use directly in Python via cppyy. Same with the `gInterpreter`.
The PyROOTWrapper is a small piece of code that is only used in PyROOTModuce.cxx, so I don't think it needs its own translation unit.
6aef770
to
2f3f8cd
Compare
2f3f8cd
to
53a4245
Compare
Thank you so much Vincenzo for fixing it up! |
This is not necessary if we consider that
gROOT
is actually apreprocessor macro that aliases to
ROOT::GetROOT()
, which we can usedirectly in Python via cppyy. Same with the
gInterpreter
.Also, a second commit refactors the PyROOT C++ code to avoid some boilerplate by having too granular translation units.