Closed cozzyd closed 6 months ago
Hi,
I can reproduce the issue. Please try to first import crpropa, and then the plugin, which works for me:
In [1]: import myPlugin
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[...]
TypeError: Could not create type 'MyModule' as base 'crpropa::Module' has not been initialized.
In [2]: import crpropa
In [3]: import myPlugin
In [4]:
However, this import should be done ideally automatically, or at least this should be added to the documentiaton.
Hi Tobias,
That does not work for me (in fact, testPlugin.py already imports crpropa first).
However, looking at the generated SWIG code for the test plugin, I see:
#define SWIGPYTHON_BUILTIN
I'm not sure exactly what that means, but crpropa was apparently configured (automatically) without ENABLE_SWIG_BUILTIN for me. If I turn on ENABLE_SWIG_BUILTIN, then the plugin works.
OK - Not enabling swig builtin is the current default due to a swig bug: https://github.com/CRPropa/CRPropa3/issues/264, which is supposed to be fixed only in 4.0.2. however, we probably still should adapt the plugin.
I see, yeah, the plugin "worked" with builtin enabled, but it's broken in current swig. It seems like just taking -builtin out of the CMakeLists.txt (line 35) for the plugin template is sufficient to make it work properly for now. I guess ideally you'd want it to pick up whether or not it should use builitin from the crpropa installation itself. This could probably be done inside findCRPropa.py by adding a crpropa.useSwigBuiltin(), although there are probably simpler ways to do it.
I guess we can close this issue with the adaptions introduced in #466 and because swig 4.0.2 became more or less available wide spread. If the problem persists please reopen the issue.
Describe the bug
I try to compile the plugin template, which links properly, but when I try to import, it fails with: TypeError: Could not create type 'MyModule' as base 'crpropa::Module' has not been initialized.
This is with the latest release of
Is the bug related to the physics in CRPropa?
No.
To Reproduce
Expected behavior I expect the testPlugin to import without issue.
System (please complete the following information):
Additional context
crpropa otherwise works fine. As far as I can tell, this fails with both the release and master branches.