|
4 | 4 | import platform
|
5 | 5 | from dataclasses import dataclass as py_dataclass, is_dataclass as py_is_dataclass
|
6 | 6 | from goto import with_goto
|
7 |
| -from numpy import get_include |
8 |
| -from distutils.sysconfig import get_python_inc |
9 | 7 |
|
10 | 8 | # TODO: this does not seem to restrict other imports
|
11 | 9 | __slots__ = ["i8", "i16", "i32", "i64", "u8", "u16", "u32", "u64", "f32", "f64", "c32", "c64", "CPtr",
|
@@ -728,19 +726,24 @@ def get_data_type(t):
|
728 | 726 | # TODO: Use LLVM instead of C backend
|
729 | 727 | r = os.system("lpython --show-c --disable-main a.py > a.h")
|
730 | 728 | assert r == 0, "Failed to create C file"
|
| 729 | + |
731 | 730 | gcc_flags = ""
|
732 | 731 | if platform.system() == "Linux":
|
733 | 732 | gcc_flags = " -shared -fPIC "
|
734 | 733 | elif platform.system() == "Darwin":
|
735 | 734 | gcc_flags = " -bundle -flat_namespace -undefined suppress "
|
736 | 735 | else:
|
737 | 736 | raise NotImplementedError("Platform not implemented")
|
| 737 | + |
| 738 | + from numpy import get_include |
| 739 | + from distutils.sysconfig import get_python_inc |
738 | 740 | python_path = "-I" + get_python_inc() + " "
|
739 | 741 | numpy_path = "-I" + get_include()
|
740 | 742 | rt_path_01 = "-I" + get_rtlib_dir() + "/../libasr/runtime "
|
741 | 743 | rt_path_02 = "-L" + get_rtlib_dir() + " -Wl,-rpath " \
|
742 | 744 | + get_rtlib_dir() + " -llpython_runtime "
|
743 | 745 | python_lib = "-L" "$CONDA_PREFIX/lib/ -lpython3.10 -lm"
|
| 746 | + |
744 | 747 | r = os.system("gcc -g" + gcc_flags + python_path + numpy_path +
|
745 | 748 | " a.c -o lpython_jit_module.so " + rt_path_01 + rt_path_02 + python_lib)
|
746 | 749 | assert r == 0, "Failed to create the shared library"
|
|
0 commit comments