I'm following the C Python extension tutorial to create new type.
I created the file custom.c
, setup.py
and added the following line to my CMakeLists.txt
:
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND ${PYTHON_BIN} setup.py build)
But when I run
Py_Initialize();
PyImport_AddModule("custom"));
PyRun_SimpleString("import custom\nmycustom = custom.Custom()");
PyErr_Print();
I got Attribute error: module 'custom' has no attribute 'Custom'
even if I add the path to generated .pyd to sys.path
Python help on module is
Help on module custom:
NAME
custom
FILE
(built-in)
I am running on Windows 10 with Python 3.8
But I can import and use the module directly from a Python terminal