Skip to main content

Jupyter extension which executes Rust functions in Python

Project description

rustdef

Test PyPI version

Jupyter extension for jupyter notebooks and rust users.

You can define functions in rust and run them as python functions. This extension is built on PyO3 and maturin.

Examples

Prerequisite

Install

$ pip install rustdef

Usage

Define rust functions,

%%rustdef
#[pyfunction]
fn my_func(x: i64, y: &str) -> i64 {
    println!("{}", y);
    x + y.len() as i64
}

Add dependencies, (e.g. num crate)

%rustdef deps add num@0.4.0

Defined dependencies are valid only in the current notebook.

Show dependencies,

%rustdef deps show
num = "0.4.0"

[pyo3]
version = "0.13.2"
features = [ "extension-module",]

pyo3 is included by default.

Develop

How does it work?

Roughly, definitions in rustdef are available in python after the following steps.

  1. Each rustdef magic cell is populated with the module definition of pyo3
  2. A new crate is generated for the rustdef cell
  3. The crate is compiled into a python wheel by maturin
  4. Install the wheel with pip
  5. Functions with #[pyfunction] attributes are exported into the interpreter namespace in notebooks
  6. Ready to call the function in notebooks!

Build

maturin is required.

$ pip install maturin
$ maturin build
$ pip install target/wheels/rustdef-{version}-{python}-{platform}.whl

ToDo

  • execute within rustdef cell
  • class/module supports
  • customizable module name
  • use functions defined in another cell
  • verbose flag
  • serde support
  • windows support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl (855.6 kB view details)

Uploaded CPython 3.11 macOS 10.7+ x86-64

rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl (855.6 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl (855.6 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.34+ x86-64

rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl (855.3 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.34+ x86-64

rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl (855.2 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

File details

Details for the file rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 665440215993540240240745f2cf34229e4a8373de348a8b3e75946af25cfb33
MD5 748d0894bc2a1669956489bd78be86a4
BLAKE2b-256 fac4685584cfc30926c0c4d79083f07de769dbf42da00eccb5b13ef93c7bf142

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0c6e5d26bc8b6649720a96353a568c83a7b1b01a7db89938d9f606259c7c6933
MD5 b3764c978d9722db3362e13a138520db
BLAKE2b-256 7d0db7a74d4366babda1bbd22aa37bc4de8c1fe56e0f15346edea2c5a0a8ee26

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2f9037d9dfe0651546ba6841abd7b1e1c127d98153f15f74f4595228f8e36259
MD5 abb8c0c17976c1e6b9a804e9506b47ee
BLAKE2b-256 60812c39ab79fdf49a72fc1f74f8701ad038289fa21f5a00e3b006267d60c1d5

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 fdf49d685023abaa66cd7ee6d8a359f4bd5015a536c67ed1eec5a0420573c282
MD5 5de92d57df628b039f35a480e7738fc5
BLAKE2b-256 97c1b308ac86e8f635134f063b8f87277ecca5d2cc997112648bd02e176300c1

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1ddc9002d95c6f4025115916bd3c619271f193acf70d7ce7177f9e438fbc1f46
MD5 b2c3ad54fb47f3ea5f6f93571218a1dc
BLAKE2b-256 271160f4706289133e6b07cc6848cc9ed709302a356087dde4c4f59cf1d98f24

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 589095778f54d2a4002414222597da5649b717a113ae79fed8b83cee2bde4f3e
MD5 5d856b33cbce5c6839f19fe7355f2a20
BLAKE2b-256 4cf03f7f9fca8f1f4b38b0d51b8cffaa5914ea81067bfe21b0a2464eed62ef8d

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a595fbdcae5e8ba9b4c7c62bb3cf6f8bf940dabada189fa024f99fc259dec3fa
MD5 264fde7a7f8bfe5713909614002e2983
BLAKE2b-256 047ed6612e3b6a1bfd4d42ee4b3eac0edc229afd14a0eb5b650352ed81f266a5

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2442e568afc416a998be26eed235b513c8ecb4838b9c60bf3564974e516f7ca7
MD5 4d50c30dfaa24e363664578af7dfb26f
BLAKE2b-256 97fc28e7701052f840911bb648e9bec6f12f80d0895b3ee342a1eb0923ca3203

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7405adc859c907e665db34c3b9f85fc70207baa4eb1880c140207e3fa6278bb5
MD5 3e48a77903b5c89a5998357d99c11cb2
BLAKE2b-256 c9c892ecddea9b240dcb8921ef9de7d8074ca8e1a8dab46606ce881e97f76e24

See more details on using hashes here.

File details

Details for the file rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2aeff62028949b20d93975164e244296f26365a381ae0f7a89328e5ba6352119
MD5 bb7514c56c5976eeb949bc7e81280d74
BLAKE2b-256 e3e3b99361013af4dbcdfe3a5e7967ca4c62030a9a4122da7377b45dc7e5a535

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page