Skip to content

Building a Python package that uses Rust #1973

@josephrocca

Description

@josephrocca

🚀 Feature

Tooling and/or docs to support building Python packages that contain Rust code.

Motivation

I was in the process of (attempting to) create a JS/wasm build of Hugging Face Tokenizers when I realised that it might just be easier/better for my use case to load it with Pyodide (especially since I might want to use Python packages that depend upon Tokenizers. The docs show how to build a Python package that uses C (with emscripten), but not Rust.

Rust has great, simple wasm build support via wasm-pack. After annotating the Rust functions/modules that you want to export (and installing wasm pack with cargo install wasm-pack) it's just a single wasm-pack build --target=web --out-dir=wasm to get the wasm and glue files. Here's a hello world tutorial.

So I'm wondering: Is this feasible now with the right configuration, or is there some extra work on the Pyodide dev tooling to get this working? If it's not possible with the current tooling, what might be the steps required to make it possible?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions