[Python] Don't import cppyy in ROOT facade module #21091
Merged
+138
−160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The setup of the ROOT module roughly works like this:
cppyymodulesROOT module
The facade module also import cppyy.
In the future, we want to have
cppyyas an internal submodule ofROOTto separate the ROOT package cleanly from other cppyy packages.That means, the facade module will have to import something like
ROOT._cppyy, which implies the import of the ROOT module, whichimports the facade, and that's infinite recursion.
So one prerequisite for moving the
cppyymodule insideROOTis thatthe facade module doesn't import
cppyyin its global scope, which isimplemented in this commit.
Fortunately, this can easily be avoided by re-using the handle to the
cppyy module that
ROOT/__init__.pyhas originally imported, which isset as an attribute of the facade.
This commit also takes the opportunity to fixup one design flaw in
e9fe075: the handle to the original ROOT module in the facade
should not be public, because this is an implementation detail of the
was the ROOT module is constructed.
So essentially, the
ROOT.moduleattribute is replaced with a newROOT._cppyyattribute.