-
Notifications
You must be signed in to change notification settings - Fork 167
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
Importing modules does not work #1305
Comments
@Thirumalai-Shaktivel any idea why this does not work? |
Currently, we don't support from a.b import f Instead, this works: from a import f $ lpython r.py
b.f() called I will try to work on this soon. |
Fixed here: #1306 |
Ok, the above now works with #1306, but more deeply nested doesn't: $ tree a
a
├── __init__.py
├── b.py
└── c
├── __init__.py
└── d.py
(lf) repos/lpython(nested_modules_02) $ cat a/c/d.py
def g():
print("a.c.g() called")
(lf) repos/lpython(nested_modules_02) $ cat r.py
from a.b import f
f()
from a.c.d import g
g()
(lf) repos/lpython(nested_modules_02) $ python r.py
b.f() called
a.c.g() called
(lf) repos/lpython(nested_modules_02) $ lpython r.py
semantic error: Could not find the module 'a/c.d.py'. If an import path is available, please use the `-I` option to specify it
--> r.py:3:1
|
3 | from a.c.d import g
| ^^^^^^^^^^^^^^^^^^^
Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed). |
Fixed here: #1315 |
I think it works now! I can't think of any case that doesn't work, so I am going to close this issue as fixed. If we discover more things that don't work, I'll open a new issue. @Thirumalai-Shaktivel, @czgdp1807 are we ready now to start making Python packages that compile with LPython? |
I came across another issue that doesn't work yet. Like for this example: import test_import
def test():
print(test_import.print_a())
print(test_import.print_b())
print(test_import.print_c())
test() Error: lpython integration_tests/test_import_01.py
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
Binary file "/home/thirumalai/Open_Source/lpython/src/bin/lpython", in _start()
File "./csu/../csu/libc-start.c", line 392, in __libc_start_main_impl()
File "./csu/../sysdeps/nptl/libc_start_call_main.h", line 58, in __libc_start_call_main()
File "/home/thirumalai/Open_Source/lpython/src/bin/lpython.cpp", line 1545, in ??
err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir, lpython_pass_manager, compiler_options, time_report);
File "/home/thirumalai/Open_Source/lpython/src/bin/lpython.cpp", line 592, in ??
!(arg_c && compiler_options.disable_main), infile);
AssertFailed: asr_verify(*tu, true, diagnostics) I will try to work on this later this week. After that, I think we are ready to start making python packages. |
Can you open up a dedicated issue for this and close this issue? |
At least I will start writing code in a modular way and compile it using LPython. Probably by the end of this week or early next week. |
Yup, that would be very helpful. That way, we can test and report any bugs. |
I referenced this as a new issue. |
Thanks! |
This gives:
The text was updated successfully, but these errors were encountered: