Skip to content

Add examples showcasing how to embed RustPython in Rust applications #1707

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

Merged
merged 5 commits into from
Jan 27, 2020

Conversation

cedric-h
Copy link
Contributor

I'm sure examples like these were left out because you can just comb through the source, the documentation, pyckitup, etc. and figure out how everything works, and while that's definitely the case (I mean, I just did exactly that) doing so is quite time consuming, so I hope that I can leave these tutorials as breadcrumbs for anyone else who's interested in embedding RustPython into their applications.

I can say that personally I encountered RustPython a couple months back, and because there were no examples like these I simply assumed that embedding RustPython into Rust applications wasn't possible/feasible, and that it was meant simply to be a standalone application. Examples like these and the note in the README should make it much clearer to interested passerby that RustPython is not only embeddable into applications, but that it's also quite easy to do so.

Copy link
Member

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks! You might also want to provide an example of using the py_compile_bytecode! macro to embed Python code inside of Rust; you can look at vm/src/frozen.rs for examples of that.

@cedric-h
Copy link
Contributor Author

cedric-h commented Jan 26, 2020

We probably want more examples, especially on idiomatic Rust interop, freezing entire Python modules (instead of a single function as I do in mini_repl.rs), etc.

These are definitely a good start though.

@youknowone youknowone merged commit d8a0eec into RustPython:master Jan 27, 2020
@cedric-h cedric-h deleted the embed-examples branch January 29, 2020 01:30
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

Successfully merging this pull request may close these issues.

3 participants