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

Improved Rust py example #107

Merged
merged 6 commits into from
Jun 14, 2023
Merged

Improved Rust py example #107

merged 6 commits into from
Jun 14, 2023

Conversation

assambar
Copy link
Contributor

@assambar assambar commented Jun 13, 2023

Add helper crates for usage of libpython in Rust.

  • wlr-libpy - offers methods that download and setup all static lib dependencies necessary for linking with the pre-built libpython from Wasm Language Runtimes in wasm32-wasi modules built in Rust
  • wlr-assets - generic download and extract functionality for build assets

Improve the example, which demonstrates how to embed libpython in Rust - `python/examples/embedding/wasm-py-rs

Here is the readme - https://github.com/vmware-labs/webassembly-language-runtimes/tree/rust-py-example/python/examples/embedding/wasi-py-rs`

Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Thank you @assambar! I haven't tested my own suggestions, but the idea is that crates can be referred to locally with path, without the need to pull from GitHub -- what would enforce us to push, or use a cargo override. If we can refer to this dependency crates locally on the filesystem I think it would be great.

LGTM!

python/tools/wlr-libpy/README.md Outdated Show resolved Hide resolved
python/examples/embedding/wasi-py-rs/Cargo.toml Outdated Show resolved Hide resolved
python/examples/embedding/wasi-py-rs/Cargo.toml Outdated Show resolved Hide resolved
python/examples/embedding/wasi-py-rs/README.md Outdated Show resolved Hide resolved
python/examples/embedding/wasi-py-rs/README.md Outdated Show resolved Hide resolved
python/examples/embedding/wasi-py-rs/src/lib.rs Outdated Show resolved Hide resolved
python/tools/wlr-libpy/Cargo.toml Outdated Show resolved Hide resolved
python/tools/wlr-libpy/README.md Outdated Show resolved Hide resolved
python/tools/wlr-libpython/Cargo.toml Outdated Show resolved Hide resolved
python/tools/wlr-libpython/build.rs Outdated Show resolved Hide resolved
Co-authored-by: Rafael Fernández López <[email protected]>
Copy link
Contributor

@Angelmmiguel Angelmmiguel left a comment

Choose a reason for hiding this comment

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

LGTM! I just added a few minor comments on the different crates. I love to see how easy is to embed now our Python + Wasm build 😄

python/examples/embedding/wasi-py-rs/Cargo.toml Outdated Show resolved Hide resolved
wasi_py_rs["wasi-py-rs"] --> pyo3["pyo3"]
pyo3 --> pyo3-ffi
pyo3-ffi -..-> libpython3.11.a
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this!

python/tools/wlr-libpy/README.md Outdated Show resolved Hide resolved
python/tools/wlr-libpy/README.md Outdated Show resolved Hide resolved
python/tools/wlr-libpy/README.md Outdated Show resolved Hide resolved
python/tools/wlr-libpython/build.rs Outdated Show resolved Hide resolved
python/tools/wlr-libpython/src/lib.rs Outdated Show resolved Hide resolved
tools/wlr-assets/src/lib.rs Show resolved Hide resolved
tools/wlr-assets/src/bld_cfg.rs Show resolved Hide resolved
Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Thanks @assambar! 👏

@assambar assambar merged commit 4a8d5a0 into main Jun 14, 2023
@assambar assambar deleted the rust-py-example branch June 14, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants