Skip to content
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

How to separate Rust code into Python submodules? #5296

Open
MasterDingo opened this issue May 4, 2024 · 2 comments
Open

How to separate Rust code into Python submodules? #5296

MasterDingo opened this issue May 4, 2024 · 2 comments

Comments

@MasterDingo
Copy link

Summary

I want to organize my code into submodules. How can I achive this?

Details

Say, I want to make such a structure:

from my_module import foo
from my_module.submodule import bar

I thought the following code makes it:

#[pyclass(name = "submodule", sub)]
mod submodule {
    #[pyfunction]
    pub fn bar() {
        ...
    }
}

#[pyclass(name = "my_module", with(submodule)]
mod my_module {
    #[pyfunction]
    pub fn foo() {
        ...
    }
}

But instead I got bar() inside of my_module, without any submodules.
What am I doing wrong?

@eddoss
Copy link

eddoss commented May 4, 2024

You can find the answer is here https://discord.com/channels/1043121930691149845/1235678739707199528
I faced the same problem 1 day ago

@MasterDingo
Copy link
Author

You can find the answer is here https://discord.com/channels/1043121930691149845/1235678739707199528 I faced the same problem 1 day ago

Thank you very much, I finally did it almost the same way :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants