Call extension module from extension module using Numba AoT

202 Views Asked by At

I develop complex math library in Python using numba. Any functions must support jit and aot. I have functions calling functions from another file.

func1.py:

from numba.pycc import CC
from numba import njit

cc = CC('func1')


@njit
@cc.export('calc', 'f8(f8, f8)')
def calc(a, b):
    return a + b

func1.py compiles into func1.cp38-win_amd64.pyd using cc.compile()

func2.py:

import func1 as func
from numba import njit
from numba.pycc import CC

cc = CC('func2')


@njit
@cc.export('calc', 'f8(f8, f8)')
def calc(a, b):
    return func.calc(a, b)

If I try to compile func2.py, an error is thrown:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend) Unknown attribute 'calc' of type Module(<module 'func1' from '...\func1.cp38-win_amd64.pyd'>)

Can I call extension module from extension module and how to do it right?

0

There are 0 best solutions below