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

[PyROOT] Don't add gROOT and other globals manually to PyROOT via C++ #16869

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

guitargeek
Copy link
Contributor

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.

Also, a second commit refactors the PyROOT C++ code to avoid some boilerplate by having too granular translation units.

Copy link
Member

@vepadulano vepadulano left a 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()
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@guitargeek guitargeek force-pushed the pyroot_groot branch 4 times, most recently from 167ea46 to 292d8b1 Compare November 8, 2024 16:17
@guitargeek guitargeek force-pushed the pyroot_groot branch 4 times, most recently from e86ffd9 to 6973248 Compare November 9, 2024 00:11
Copy link

github-actions bot commented Nov 9, 2024

Test Results

    20 files      20 suites   4d 5h 19m 13s ⏱️
 2 700 tests  2 493 ✅ 1 💤 206 ❌
51 261 runs  51 055 ✅ 0 💤 206 ❌

For more details on these failures, see this check.

Results for commit 6aef770.

♻️ This comment has been updated with latest results.

Copy link
Member

@vepadulano vepadulano left a 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

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.
@guitargeek
Copy link
Contributor Author

Thank you so much Vincenzo for fixing it up!

@guitargeek guitargeek merged commit 990c31e into root-project:master Nov 12, 2024
20 of 22 checks passed
@guitargeek guitargeek deleted the pyroot_groot branch November 12, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants