-
Notifications
You must be signed in to change notification settings - Fork 170
Pythoncall: Support arrays of int, real as args #1931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d3fadd7
to
4f13699
Compare
@@ -1,4 +1,4 @@ | |||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | |||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the cmake minimum version here. cmake
with version 3.5
is unable to find python
from the conda
environment (It always picks the system level python
). It seems cmake
with version 15
and above supports finding python from conda
environment (reference https://gitlab.kitware.com/cmake/cmake/-/issues/21322#note_845923). Python
from conda environment is needed as the conda environment contains the installed numpy package.
Doubt related to return types as arrays: $ cat expr2.py
from lpython import pythoncall, f32
@pythoncall(module = "expr2_module")
def return_multi_dim_arr() -> f32[2, 3]:
pass
def main0():
x: f32[2, 3] = return_multi_dim_arr()
print("x = ", x)
main0()
$ cat expr2_module.py
import numpy as np
def return_multi_dim_arr():
a = np.array([3.12, -2.14, 1., 4., 5., 6.]).reshape((2, 3))
print("CPython: ", a)
return a In the above example, the function How do we tackle this? Shall we skip updating/modifying CC: @certik, @czgdp1807, @Smit-create |
@@ -1562,6 +1565,7 @@ int main(int argc, char *argv[]) | |||
app.add_flag("--get-rtl-dir", print_rtl_dir, "Print the path to the runtime library file"); | |||
app.add_flag("--verbose", compiler_options.verbose, "Print debugging statements"); | |||
app.add_flag("--enable-cpython", compiler_options.enable_cpython, "Enable CPython runtime"); | |||
app.add_flag("--enable-cnumpy", compiler_options.enable_cnumpy, "Enable C-Numpy runtime"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it
app.add_flag("--enable-cnumpy", compiler_options.enable_cnumpy, "Enable C-Numpy runtime"); | |
app.add_flag("--enable-numpy", compiler_options.enable_numpy, "Enable NumPy runtime (implies --enable-cpython)"); |
Yes. I think it skips BindC functions and we just need it to also skip BindPython functions too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great!
I am going to merge this, as it looks good. In subsequent PRs:
|
We can support this. A minor concern here is that people/users might get confused as |
I see. Maybe we can call it |
towards #703
This PR supports passing of arrays of types int, real to @ pythoncall decorated functions. Returning arrays of simple types is yet to be supported.