0

I am writing Python extension modules for my C++ application. Also, I embedded Python interpreter in the same application and use these modules. So, I am not building separately these extension modules, because modules are created and used in the same application (just add PyImport_AppendInittab("modulename", &PyInit_modulename) before the Py_Initialize()). If I do it like this is it possible to create Python package structure? Currently, I have import module, but I need to have the possibility to use import package.module in my embedded Python interpreter. Is there anything for creating packages like there is a function for modules PyModule_Create()?

kjrkvc
  • 115
  • 2
  • 12

1 Answers1

0

My further research shows that it is not possible to have packages structure in extension modules. Actually, you can create the structure using a simple trick, add a module to existing module as an object. For example, you can create the structure like this: mod1.mod2.mod3. But, it's not same like packages. You cannot use import mod1.mod2 or import mod1.mod2.mod3. You have to use import mod1, and that will import all modules. No way to import just one module.

kjrkvc
  • 115
  • 2
  • 12