Skip to content

Commit

Permalink
Move import statements within the lpython class
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed May 12, 2023
1 parent 37827ef commit a4df75c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/lpython/lpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import platform
from dataclasses import dataclass as py_dataclass, is_dataclass as py_is_dataclass
from goto import with_goto
from numpy import get_include
from distutils.sysconfig import get_python_inc

# TODO: this does not seem to restrict other imports
__slots__ = ["i8", "i16", "i32", "i64", "u8", "u16", "u32", "u64", "f32", "f64", "c32", "c64", "CPtr",
Expand Down Expand Up @@ -728,19 +726,24 @@ def get_data_type(t):
# TODO: Use LLVM instead of C backend
r = os.system("lpython --show-c --disable-main a.py > a.h")
assert r == 0, "Failed to create C file"

gcc_flags = ""
if platform.system() == "Linux":
gcc_flags = " -shared -fPIC "
elif platform.system() == "Darwin":
gcc_flags = " -bundle -flat_namespace -undefined suppress "
else:
raise NotImplementedError("Platform not implemented")

from numpy import get_include
from distutils.sysconfig import get_python_inc
python_path = "-I" + get_python_inc() + " "
numpy_path = "-I" + get_include()
rt_path_01 = "-I" + get_rtlib_dir() + "/../libasr/runtime "
rt_path_02 = "-L" + get_rtlib_dir() + " -Wl,-rpath " \
+ get_rtlib_dir() + " -llpython_runtime "
python_lib = "-L" "$CONDA_PREFIX/lib/ -lpython3.10 -lm"

r = os.system("gcc -g" + gcc_flags + python_path + numpy_path +
" a.c -o lpython_jit_module.so " + rt_path_01 + rt_path_02 + python_lib)
assert r == 0, "Failed to create the shared library"
Expand Down

0 comments on commit a4df75c

Please sign in to comment.