Skip to content

Commit 3c5909d

Browse files
Import the shared library and return the function call
1 parent bf0a910 commit 3c5909d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/lpython/lpython.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from inspect import getfullargspec, getcallargs, isclass
1+
from inspect import getfullargspec, getcallargs, isclass, getsource
22
import os
33
import ctypes
44
import platform
55
from dataclasses import dataclass as py_dataclass, is_dataclass as py_is_dataclass
66
from goto import with_goto
7+
from numpy import get_include
8+
from distutils.sysconfig import get_python_inc
79

810
# TODO: this does not seem to restrict other imports
911
__slots__ = ["i8", "i16", "i32", "i64", "f32", "f64", "c32", "c64", "CPtr",
@@ -726,3 +728,8 @@ def get_data_type(t):
726728
" a.c -o lpython_jit_module.so " + rt_path_01 + rt_path_02 + python_lib)
727729
assert r == 0, "Failed to create the shared library"
728730

731+
def __call__(self, *args, **kwargs):
732+
import sys; sys.path.append('.')
733+
# import the symbol from the shared library
734+
function = getattr(__import__("lpython_jit_module"), self.fn_name)
735+
return function(*args, **kwargs)

0 commit comments

Comments
 (0)