Skip to content

Commit 9c5d539

Browse files
authored
Merge pull request #206 from corywalker/corywalker
Update Jupyter Notebook support.
2 parents 868399e + b5555de commit 9c5d539

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ __debug_bin
1616
.idea/workspace.xml
1717

1818
dist/
19+
20+
venv/
21+
iwolfram/
22+
expreduce_for_jupyter
23+
.ipynb_checkpoints/
24+
*.ipynb

expreduce/evalstate.go

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ func (es *EvalState) Init(loadAllDefs bool) {
122122
es.MarkSeen("System`TeXForm")
123123
es.MarkSeen("System`OutputForm")
124124
es.MarkSeen("System`FullForm")
125+
// Just a hack so that we can use
126+
// https://github.com/mmatera/iwolfram/blob/76fae74c5f1d733f02be7d2cfe2617bc48c7111e/wolfram_kernel/init.m#L220
127+
// easily. Not an actual symbol.
128+
es.MarkSeen("System`ShowForm")
125129
es.MarkSeen("System`TraditionalForm")
126130
es.MarkSeen("System`StandardForm")
127131

scripts/start_jupyter.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Building Expreduce kernel..."
6+
go build -o expreduce_for_jupyter
7+
8+
# Set the virtual environment directory
9+
VENV_DIR="venv"
10+
11+
# Check if the virtual environment exists
12+
if [ ! -d "$VENV_DIR" ]; then
13+
echo "Creating virtual environment..."
14+
python3 -m venv "$VENV_DIR"
15+
fi
16+
17+
# Activate the virtual environment
18+
source "$VENV_DIR/bin/activate"
19+
20+
# Upgrade pip
21+
echo "Upgrading pip..."
22+
pip install --upgrade pip
23+
24+
pip install nbclassic
25+
26+
# Install Jupyter if not already installed
27+
if ! pip show jupyter > /dev/null 2>&1; then
28+
echo "Installing Jupyter..."
29+
pip install notebook
30+
fi
31+
32+
pip install setuptools
33+
34+
pip install metakernel --upgrade
35+
36+
# TODO(corywalker): Switch back to upstream once pull requests are merged.
37+
[ -d "iwolfram" ] || git clone https://github.com/corywalker/iwolfram.git
38+
cd iwolfram
39+
python setup.py install --mma-exec ../expreduce_for_jupyter
40+
41+
# Run Jupyter Notebook
42+
echo "Starting Jupyter Notebook..."
43+
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
44+
45+
# Deactivate the virtual environment on exit
46+
deactivate

0 commit comments

Comments
 (0)