-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement import by using importlib #958
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
Comments
An initial implementation can be found in #1018. |
Another thing that would help this is supporting |
This can be closed not that #1018 was merged |
UPD: Related to #55
from .result import TestResult Example:
from .second import value
value = 1 Expected resultpython -c 'import module; print(module.value)'
Current resultcargo run -- -c 'import module; print(module.value)'
|
Additional investigation - CPython does level magic in compile: python -c "import dis; dis.dis(compile('from .second import value', '', 'exec'))"
(note second dot) python -c "import dis; dis.dis(compile('from ..second import value', '', 'exec'))"
|
@apatrushev please look at the implementation of the relative import at #1050. |
I took a short look on the code in PR. Unfortunately I have no strong opinion on where to place this code in compile or in vm execution because I am not confident neither in CPython code nor in RustPython. And I have no idea why CPython doing this in compile time - I just put my investigations here for the history to save the time later. Besides this disclaimer your code LGTM (and |
@Skinny121, @apatrushev can we close this issue? |
Uh oh!
There was an error while loading. Please reload this page.
The standard library for Python contains importlib, which contains a pure* Python implementation of the import machinery. This is lucky as we then don't have to implement it all in Rust. But we have to bootstrap it and implement all of the functionality it uses from builtin modules.
This is blocked by the following:
* Uses built-in module _imp to actually create module objects.
The text was updated successfully, but these errors were encountered: