cookiecutter-cppyy-cmake
cookiecutter-cppyy-cmake copied to clipboard
Question on python modules
First, thank you for this cookiecutter recipe. It has been a very helpful starting point for our project.
I think we have most things working well. However, I was wondering if you could help with a specific "issue". It's not a serious one, it just creates unnecessary code.
If you try to import a class from the namespace in Python, you cannot. You always have to namespace-qualify your reference. So, if I have a class in cpp namespace cppproject called foo, I may want to:
from cppproject import LogLevels
and then use LogLevels instead of cppproject.LogLevels in my Python code.
However, if I try the import, I get this:
`In [1]: import cppyy_test_bindings
Module cppyy_test_bindings.libcppyy_test_bindingsCppyy not importable in path ['/home/mbohan/source/cppyy-test-bindings/build', '/home/mbohan/anaconda3/bin', '/home/afrancis/source/common', '/home/afrancis/source/battery/common', '/home/mbohan/anaconda3/lib/python37.zip', '/home/mbohan/anaconda3/lib/python3.7', '/home/mbohan/anaconda3/lib/python3.7/lib-dynload', '/home/mbohan/.local/lib/python3.7/site-packages', '/home/mbohan/anaconda3/lib/python3.7/site-packages', '/home/mbohan/anaconda3/lib/python3.7/site-packages/IPython/extensions', '/home/mbohan/.ipython']. In [2]: from cppyy_test_bindings import cppproject
In [3]: from cppproject import LogLevels
ModuleNotFoundError Traceback (most recent call last)
ModuleNotFoundError: No module named 'cppproject'`
Python doesn't see cppproject as a module, so I can't import members from it.
Is there any way to do this? If not, we can continue to cppproject.x for every member we want to access.