-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db182e3
Showing
6 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "notebook_hello" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
start_notebook: | ||
uv run --with jupyter jupyter lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
# Jupyter Notebook with a Rust, R, and python kernel | ||
|
||
Steps to get it working: | ||
|
||
1. Install `uv`. See https://docs.astral.sh/uv/getting-started/installation/ | ||
|
||
2. Start a new project: | ||
|
||
``` | ||
uv init notebook_hello | ||
cd notebook_hello | ||
``` | ||
|
||
3. Add the python kernel you prefer, e.g. version 3.13 | ||
|
||
``` | ||
uv add --dev ipykernel | ||
uv run ipython kernel install --user --name notebook_hello | ||
uv run --python 3.13 --with jupyter jupyter lab | ||
``` | ||
|
||
4. Set up the R kernel | ||
|
||
- Install `R`. See https://www.r-project.org/ | ||
- Set up the R kernel | ||
|
||
``` | ||
Rscript -e "install.packages('IRkernel'); IRkernel::installspec(); " | ||
``` | ||
|
||
5. Set up the Rust kernel | ||
|
||
- Install Rust. See https://www.rust-lang.org/tools/install | ||
|
||
``` | ||
cargo install jupyter | ||
cargo install evcxr_jupyter | ||
``` | ||
|
||
6. Run the notebook server | ||
|
||
``` | ||
uv run --with jupyter jupyter lab | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
You should see a notebook with the option to switch between Rust, Python, and R kernels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7efbb7d8-071f-404f-8924-2bbacb9cdee6", | ||
"metadata": {}, | ||
"source": [ | ||
"# Jupyter Notebook with a Rust, R, and python kernel\n", | ||
"\n", | ||
"Steps to get it working:\n", | ||
"\n", | ||
" - install `uv`. See https://docs.astral.sh/uv/getting-started/installation/\n", | ||
" - install `R`. See https://www.r-project.org/\n", | ||
" - install Rust. See https://www.rust-lang.org/tools/install\n", | ||
"\n", | ||
"```\n", | ||
"uv init notebook_hello\n", | ||
"cd notebook_hello\n", | ||
"uv add --dev ipykernel\n", | ||
"uv run ipython kernel install --user --name notebook_hello\n", | ||
"uv run --with jupyter jupyter lab \n", | ||
"```\n", | ||
"\n", | ||
"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "82a05c78-c286-4282-88fc-5326be727f15", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Hello, Rustaceans!!\n", | ||
"Rust compiler version: rustc 1.83.0 (90b35a623 2024-11-26)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"// NB: Manually, switch to Rust kernel first\n", | ||
"use std::process::Command;\n", | ||
"let output = Command::new(\"rustc\")\n", | ||
" .arg(\"--version\")\n", | ||
" .output()\n", | ||
" .expect(\"Failed to get Rust version\");\n", | ||
"let rust_version = String::from_utf8_lossy(&output.stdout).to_string();\n", | ||
"println!(\"Hello, Rustaceans!!\");\n", | ||
"println!(\"Rust compiler version: {}\", rust_version.trim());\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "e2b37822-dc3d-4a34-ad03-659903f98315", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Hello, R users!\n", | ||
" R version 4.4.2 (2024-10-31)" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"## NB: Manually switch to the R kernel first\n", | ||
"cat(\"Hello, R users!\\n\", R.version$version.string)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "ea2d5308-7839-43a6-a80b-3ff12c7e6bf0", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Hello, Python users!\n", | ||
"Python 3.11.4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(f\"Hello, Python users!\")\n", | ||
"!python --version" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d9cfdfa6-5948-43ea-866e-d8c8f85ecca8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Rust", | ||
"language": "rust", | ||
"name": "rust" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "rust", | ||
"file_extension": ".rs", | ||
"mimetype": "text/rust", | ||
"name": "Rust", | ||
"pygment_lexer": "rust", | ||
"version": "" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |