-
Notifications
You must be signed in to change notification settings - Fork 100
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
Scaling PyO3 down with single-file Python extensions #344
Comments
As an alternative to the above syntax, the config part could be specified in |
Some reasons this might be a bad idea:
|
I think if one goes automatically generating a |
One alternative I just discovered to the proposal here is https://github.com/mityax/rustimport I'll try playing around with it, and report what I've learned here. |
It seems to me that once the cargo-script RFC is stable, it'd be a much smaller amount of work to build this on top of that. |
So I played around with So from my perspective it's probably not worth spending a lot of time on adding it to |
Another alternative: https://www.maturin.rs/develop.html#import-hook |
One nice thing about Cython is that you can have a single
.pyx
file, two lines insetup.py
and one line inrequirements.txt
, and you're good. With PyO3, you need a Cargo.toml, configured a particular way (cdylib), and so it's just a bit more ceremony than Cython for simple cases.Maturin is great for standalone libraries, but doesn't help simplify the case of adding a quick extension to an existing Python project.
To solve this, one could imagine single-file Rust extension modules, inspired by https://github.com/rust-lang/rfcs/blob/master/text/3424-cargo-script.md (and see the references to existing tools that predate the RFC, mostly for executables). You might then have:
And the
setup.py
is modified to point at_extension.rs
, much like you would with Cython, rather than pointing atCargo.toml
as it normally does:The
_extension.rs
might look like this:Once you start thinking about lock files this starts getting more complicated, they could be auto-generated as
mypackage/_extension.rs.lock
, and you'd need some way to update them... conceivably could outsource that to Cargo eventually if the feature becomes non-experimental and they are willing to add a new use case.The text was updated successfully, but these errors were encountered: