Skip to content

Commit b53f1d4

Browse files
authored
Merge pull request #99 from Dyalog/notebook-v7
Dyalog jupyter kernel v.2.0.0
2 parents 421dd51 + 44c1a0d commit b53f1d4

15 files changed

+316
-49
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Mac stuff
2+
.DS_Store
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
pip-wheel-metadata/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Jupyter Notebook
58+
.ipynb_checkpoints
59+
60+
# pyenv
61+
.python-version
62+
63+
# Environments
64+
.env
65+
.venv
66+
env/
67+
venv/
68+
ENV/
69+
env.bak/
70+
venv.bak/
71+
72+
# Spyder project settings
73+
.spyderproject
74+
.spyproject
75+
76+
# Rope project settings
77+
.ropeproject
78+
79+
# mkdocs documentation
80+
/site
81+
82+
# mypy
83+
.mypy_cache/
84+
.dmypy.json
85+
dmypy.json
86+
87+
# Pyre type checker
88+
.pyre/
89+
90+
# pyright
91+
.pyrightcache/
92+
93+
# VSCode
94+
.vscode/

DEVELOPMENT.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## Developing and publishing the Dyalog Jupyter kernel
2+
3+
We release from the master branch, and use semantic versioning. Releases are defined by the tag name. Find the current tag by
4+
5+
```
6+
git describe --tags `git rev-list --tags --max-count=1`
7+
```
8+
9+
For patch releases, add 1 to the last component of the current tag.
10+
11+
Update the `__version__` string in `dyalog_kernel/__main__.py` accordingly, and the `version` key in `setup.py`.
12+
13+
The patch level should reset if we're changing major or minor version components, following semver.
14+
15+
Build release assets with
16+
17+
```sh
18+
python setup.py sdist bdist_wheel
19+
```
20+
21+
Built assets will end up in `dist/`, and you can instruct `pip` to install from file for testing:
22+
23+
```sh
24+
pip install dist/dyalog-jupyter-kernel-x.y.z.tar.gz
25+
```
26+
27+
Now tag the master branch with the new version (prefixed by `v.`):
28+
29+
```
30+
git tag -a v2.0.1 -m "Release version 2.0.1"
31+
git push origin v2.0.1
32+
```
33+
34+
Upload release assets using [twine](https://twine.readthedocs.io/en/stable/). Install `twine` with
35+
36+
```sh
37+
pip install twine
38+
```
39+
40+
Pick up the API token, and set up your `$HOME/.pypirc` file like this:
41+
42+
```
43+
[distutils]
44+
index-servers =
45+
pypi
46+
testpypi
47+
48+
[pypi]
49+
username = __token__
50+
password = pypi-A...Z # Replace with your actual PyPI API token
51+
52+
[testpypi]
53+
username = __token__
54+
password = pypi-A...Z # Replace with your actual TestPyPI API token
55+
```
56+
57+
Use the API key(s) as password, including the `pypi-` prefix.
58+
59+
Upload the release to the test index first, and test that:
60+
61+
```sh
62+
twine upload --repository testpypi dist/*
63+
```
64+
65+
To install the module from the test index, use
66+
67+
```sh
68+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple dyalog-jupyter-kernel[==2.0.1]
69+
python -m 'dyalog_kernel' install
70+
```
71+
The `--extra-index-url` argument is there so that `pip` can pick up any dependencies from the main index.
72+
73+
Upload the release to the main index, and test that:
74+
75+
```sh
76+
twine upload --repository pypi dist/*
77+
```

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include dyalog_kernel/kernelspec *

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,50 @@
1-
# [Jupyter](http://jupyter.org/) kernel for [Dyalog APL](https://www.dyalog.com/)
1+
# Jupyter kernel for Dyalog APL
22

3-
## What is this and how do I use it?
3+
This is a [Jupyter](http://jupyter.org/) kernel for [Dyalog APL](https://www.dyalog.com/). The [wiki](https://github.com/Dyalog/dyalog-jupyter-kernel/wiki) has more details.
44

5-
Please see [our wiki](https://github.com/Dyalog/dyalog-jupyter-kernel/wiki).
5+
For complete installation instructions from scratch on Windows, see [WINDOWS.md](WINDOWS.md) in this repository.
66

7-
## Do you have any premade notebook documents?
7+
If you're a kernel developer, see [DEVELOPMENT.md](DEVELOPMENT.md) in this repository.
8+
9+
## Do you have any pre-made notebook documents?
810

911
A collection of ready-made notebooks is available [here](https://github.com/Dyalog/dyalog-jupyter-notebooks).
12+
13+
## Installation
14+
15+
### Pre-requisites:
16+
17+
- Python version 3.8 or later. Python can be installed in several ways. We recommend the standard download from https://www.python.org/downloads/.
18+
- Jupyter: see the [official documentation](https://jupyter.readthedocs.io/en/latest/install.html) for installation instructions.
19+
20+
### Installing the Dyalog kernel
21+
22+
This kernel is installable via Python's package installer, [pip](https://pip.pypa.io/en/stable/). It comes bundled with Python, but does occasionally need updating.
23+
24+
In your terminal, run the follwing command:
25+
26+
```sh
27+
pip install dyalog-jupyter-kernel[==2.0.1]
28+
```
29+
30+
After successfully installing the kernel module itself, you need to register it with your Jupyter installation, using the following terminal command:
31+
32+
```sh
33+
python -m 'dyalog_kernel' install
34+
```
35+
36+
You should now be able to see the `dyalog_apl` kernel listed:
37+
```sh
38+
jupyter kernelspec list
39+
40+
Available kernels:
41+
python3 C:\Users\stefa\work\Jupyter\py312\share\jupyter\kernels\python3
42+
dyalog_apl C:\Users\stefa\AppData\Roaming\jupyter\kernels\dyalog_apl
43+
```
44+
45+
Start Jupyter:
46+
47+
```sh
48+
jupyter lab # or jupyter notebook
49+
```
50+
and you should now see Dyalog APL amongst your kernels. Click on the Dyalog APL icon.

WINDOWS.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# A full installation, from scratch, on Windows
2+
3+
Installing, operating and maintaining a Python installation can be a bit of a chore, especially if you're not a Python developer. If you're coming to this wanting only to use Jupyter for Dyalog APL, here are some step by step instructions for how to set up the whole tool chain (on Windows) from scratch.
4+
5+
If you're a Python developer, or if you're already using a "canned" Python distribution, like [conda](https://docs.conda.io/en/latest/), you probably know what you're doing and can skip this document.
6+
7+
The below instructions install Jupyter and the Dyalog kernel inside a Python "virtual environment". This means that you can keep your Jupyter work separate from any other Python work, current or future. This is usually a good idea when working with Python.
8+
9+
1. Download and install the [Dyalog interpreter](https://www.dyalog.com/download-zone.htm).
10+
2. Download, and run the official [Python installer](https://www.python.org/downloads/). Ensure you select `Use admin privileges to install Python`, `Add python.exe to PATH`, and `Disable PATH limit`.
11+
3. Open a PowerShell terminal. Type the following steps into the terminal window.
12+
4. Create a virtual Python environment with a name of your choosing, for example
13+
```
14+
python -m venv jupy312
15+
```
16+
5. Activate the virtual environment -- this is important:
17+
```
18+
jupy312\Scripts\activate
19+
```
20+
Your terminal prompt should change to have a `(jupy312)` prefix.
21+
6. Upgrade `pip` to the latest version:
22+
```
23+
python.exe -m pip installl --upgrade pip
24+
```
25+
7. Install `jupyterlab`:
26+
```
27+
pip install jupyterlab
28+
```
29+
8. Install the Dyalog kernel Python module:
30+
```
31+
pip install dyalog-jupyter-kernel
32+
```
33+
9. Register the kernel with Jupyter:
34+
```
35+
python -m 'dyalog_kernel' install
36+
```
37+
10. Start jupyterlab:
38+
```
39+
jupyter lab
40+
```
41+
42+
A browser window should open up with the Jupyter Lab application. Click the "Dyalog APL" symbol to open a new notebook document with the Dyalog kernel.
43+
44+
Once you're done working with Jupyter Lab, deactivate the Python environment:
45+
46+
```
47+
deactivate
48+
```
49+
50+
To start up Jupyter Lab again, you need to run `jupy312\Scripts\activate` and `jupyter lab` again.

dyalog_kernel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Dyalog APL Jupyter kernel"""
22

3-
__version__ = '0.911'
3+
__version__ = '2.0.1'
44

55
from .kernel import DyalogKernel

dyalog_kernel/__main__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
import sys
12
from ipykernel.kernelapp import IPKernelApp
23
from . import DyalogKernel
4+
from .install import install_kernel_spec
35

4-
IPKernelApp.launch_instance(kernel_class=DyalogKernel)
6+
def main():
7+
if len(sys.argv) > 1 and sys.argv[1] == 'install':
8+
install_kernel_spec()
9+
else:
10+
IPKernelApp.launch_instance(kernel_class=DyalogKernel)
11+
12+
if __name__ == '__main__':
13+
main()
File renamed without changes.
File renamed without changes.

dyalog_kernel/install.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
def install_kernel_spec():
6+
kernel_spec_path = os.path.join(os.path.dirname(__file__), 'dyalog_apl')
7+
subprocess.run([sys.executable, '-m', 'jupyter', 'kernelspec', 'install', kernel_spec_path, '--user'], check=True)

dyalog_kernel/kernel.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from ipykernel.kernelbase import Kernel
1414
from dyalog_kernel import __version__
15-
from notebook.services.config import ConfigManager
1615

1716
if sys.platform.lower().startswith('win'):
1817
from winreg import *
@@ -254,12 +253,6 @@ def __init__(self, **kwargs):
254253
self.dyalog_subprocess = subprocess.Popen([dyalog, '+s', '-q', os.path.dirname(os.path.abspath(
255254
__file__)) + '/init.dws'], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=dyalog_env)
256255

257-
# disable auto closing of brackets/quotation marks. Not very useful in APL
258-
# Pass None instead of False to restore auto-closing feature
259-
c = ConfigManager()
260-
c.update('notebook', {'CodeCell': {
261-
'cm_config': {'autoCloseBrackets': False}}})
262-
263256
Kernel.__init__(self, **kwargs)
264257

265258
self.dyalog_ride_connect()

install.bat

Lines changed: 0 additions & 6 deletions
This file was deleted.

install.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)