-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Please warn if no rust is exported in a mixed rust/python module #326
Comments
@gilescope I am having a similar problem. This took me some messing around. In the end the key was inside the init.py in the "myproj" python src dir:
Now I can import myproj.rust_ffi and also myproj.vanilla_python on the same package level. |
So while this is letting me execute the full path to functions, I have an issue with a nested module.
With this I can do:
And I can do:
But I can't do:
I get the error:
Am I doing something wrong? |
no, that's a limitation in how CPython loads extension modules. |
Okay, so I have actually found a way to fix this using some python duct tape. The fix below allows you to import normal vanilla python libs like:
As well as rust modules at depth like:
Your directory structure: ./ Your rust modules:
Inside myproj/init.py:
For each submodule from rust you want, add a directory and a init.py In each init.py put:
Finally inside import_fixer.py put:
Which begs the question, could this be autogenerated and included in pyo3? |
- See GitHub issue: PyO3/maturin#326
That is not necessary. In the pyo3_mixed example you can e.g. do |
@konstin, what are your thoughts on my solution above? |
When I create a mixed rust and python project, it seems one needs to re-export the rust into the python.
It would be great if maturin warned if nothing was imported from the rust module - i.e. the user thought it happened automagically.
The text was updated successfully, but these errors were encountered: