Skip to content

Commit a4df75c

Browse files
Move import statements within the lpython class
1 parent 37827ef commit a4df75c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/runtime/lpython/lpython.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
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
97

108
# TODO: this does not seem to restrict other imports
119
__slots__ = ["i8", "i16", "i32", "i64", "u8", "u16", "u32", "u64", "f32", "f64", "c32", "c64", "CPtr",
@@ -728,19 +726,24 @@ def get_data_type(t):
728726
# TODO: Use LLVM instead of C backend
729727
r = os.system("lpython --show-c --disable-main a.py > a.h")
730728
assert r == 0, "Failed to create C file"
729+
731730
gcc_flags = ""
732731
if platform.system() == "Linux":
733732
gcc_flags = " -shared -fPIC "
734733
elif platform.system() == "Darwin":
735734
gcc_flags = " -bundle -flat_namespace -undefined suppress "
736735
else:
737736
raise NotImplementedError("Platform not implemented")
737+
738+
from numpy import get_include
739+
from distutils.sysconfig import get_python_inc
738740
python_path = "-I" + get_python_inc() + " "
739741
numpy_path = "-I" + get_include()
740742
rt_path_01 = "-I" + get_rtlib_dir() + "/../libasr/runtime "
741743
rt_path_02 = "-L" + get_rtlib_dir() + " -Wl,-rpath " \
742744
+ get_rtlib_dir() + " -llpython_runtime "
743745
python_lib = "-L" "$CONDA_PREFIX/lib/ -lpython3.10 -lm"
746+
744747
r = os.system("gcc -g" + gcc_flags + python_path + numpy_path +
745748
" a.c -o lpython_jit_module.so " + rt_path_01 + rt_path_02 + python_lib)
746749
assert r == 0, "Failed to create the shared library"

0 commit comments

Comments
 (0)