Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/axil/rust-magic
Lightweight Rust integration in Jupyter notebook
https://github.com/axil/rust-magic
Last synced: 2 months ago
JSON representation
Lightweight Rust integration in Jupyter notebook
- Host: GitHub
- URL: https://github.com/axil/rust-magic
- Owner: axil
- License: mit
- Created: 2019-08-15T20:44:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-06T10:53:09.000Z (over 5 years ago)
- Last Synced: 2024-11-09T17:52:11.580Z (2 months ago)
- Language: Python
- Homepage:
- Size: 295 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-magic [![Build Status](https://travis-ci.org/axil/rust-magic.svg?branch=master)](https://travis-ci.org/axil/rust-magic)
Allows to try rust in Jupyter notebook. Implemented via line/cell magics:
## Installation
1. Install rust and jupyter-notebook
2. `cargo install cargo-script`
3. `pip install rust-magic`
4. Enjoy :)
## Third-party crates
are supported via normal `cargo script` syntax (see below for a more compact notation):
## Compiler options
can be provided in the cell mode:
NB [Here's](https://nbviewer.jupyter.org/github/axil/rust-magic/blob/master/example.ipynb) a copy-pastable form of all the examples above.
## Syntax highlighting
To enable rust syntax highlighting in %%rust cells run the following snippet in a python jupyter cell:
```
from notebook.services.config import ConfigManager
c = ConfigManager()
c.update('notebook', {"CodeCell": {"highlight_modes": {"text/x-rustsrc": {"reg": ["^%%rust"]}}}})
```This only needs to be run once: it stores the setting in a config file in home directory.
## Long cells
Jupyter "doesn't like" long cells: when a cell gets longer than the screen its output is not readily visible.
Here're a few ways how to handle the problem with rust_magic:a) putting dependencies into a separate cell ([more](https://nbviewer.jupyter.org/github/axil/rust-magic/blob/master/docs/deps_example.ipynb))
b) collapsing function bodies with codefolding jupyter extension
c) putting function definitions into separate cells ([more](https://nbviewer.jupyter.org/github/axil/rust-magic/blob/master/docs/funcs_example.ipynb))
## Faster compile times
can be acheived by caching dependencies compile results with [sccache](https://github.com/mozilla/sccache).
Rust-magic automatically uses it if it is installed in the system (`cargo install sccache`).