Skip to content

Commit 7dda651

Browse files
committed
Add ASDF component for lab extensions
1 parent a29c025 commit 7dda651

File tree

5 files changed

+140
-31
lines changed

5 files changed

+140
-31
lines changed

common-lisp-jupyter.asd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
(asdf:defsystem #:common-lisp-jupyter/lab-extension
2+
:components ((:module src
3+
:pathname "src/lab-extension/"
4+
:serial t
5+
:components ((:file "packages")
6+
(:file "asdf")))))
7+
18
(asdf:defsystem #:common-lisp-jupyter
29
:description "A Common Lisp kernel for Jupyter along with a library for building Jupyter kernels."
310
:author "Tarn W. Burton"

examples/about.ipynb

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,95 @@
1919
{
2020
"cell_type": "code",
2121
"execution_count": 1,
22-
"metadata": {},
22+
"metadata": {
23+
"tags": []
24+
},
2325
"outputs": [
2426
{
25-
"data": {
26-
"text/plain": [
27-
"NIL"
28-
]
29-
},
30-
"execution_count": 1,
31-
"metadata": {},
32-
"output_type": "execute_result"
33-
},
34-
{
35-
"data": {
36-
"text/plain": [
37-
"NIL"
38-
]
39-
},
40-
"execution_count": 1,
41-
"metadata": {},
42-
"output_type": "execute_result"
27+
"ename": "interrupt",
28+
"evalue": "Execution interrupted",
29+
"output_type": "error",
30+
"traceback": []
4331
},
4432
{
4533
"name": "stdout",
4634
"output_type": "stream",
4735
"text": [
48-
"Hello, World"
49-
]
50-
},
51-
{
52-
"name": "stderr",
53-
"output_type": "stream",
54-
"text": [
55-
"Goodbye, cruel World."
36+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type SIMPLE-ERROR\n",
37+
" Unsupported wildcard pattern: \"2671dab9be5a41500a382f6ac5e9ec1d-*\"\n",
38+
" Abort thread.\n",
39+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
40+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
41+
" Return to debug level 1.\n",
42+
" Abort thread.\n",
43+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
44+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
45+
" Return to debug level 2.\n",
46+
" Return to debug level 1.\n",
47+
" Abort thread.\n",
48+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
49+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
50+
" Return to debug level 3.\n",
51+
" Return to debug level 2.\n",
52+
" Return to debug level 1.\n",
53+
" Abort thread.\n",
54+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
55+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
56+
" Return to debug level 4.\n",
57+
" Return to debug level 3.\n",
58+
" Return to debug level 2.\n",
59+
" Return to debug level 1.\n",
60+
" Abort thread.\n",
61+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
62+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
63+
" Return to debug level 5.\n",
64+
" Return to debug level 4.\n",
65+
" Return to debug level 3.\n",
66+
" Return to debug level 2.\n",
67+
" Return to debug level 1.\n",
68+
" Abort thread.\n",
69+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
70+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
71+
" Return to debug level 6.\n",
72+
" Return to debug level 5.\n",
73+
" Return to debug level 4.\n",
74+
" Return to debug level 3.\n",
75+
" Return to debug level 2.\n",
76+
" Return to debug level 1.\n",
77+
" Abort thread.\n",
78+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
79+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
80+
" Return to debug level 7.\n",
81+
" Return to debug level 6.\n",
82+
" Return to debug level 5.\n",
83+
" Return to debug level 4.\n",
84+
" Return to debug level 3.\n",
85+
" Return to debug level 2.\n",
86+
" Return to debug level 1.\n",
87+
" Abort thread.\n",
88+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
89+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
90+
" Return to debug level 8.\n",
91+
" Return to debug level 7.\n",
92+
" Return to debug level 6.\n",
93+
" Return to debug level 5.\n",
94+
" Return to debug level 4.\n",
95+
" Return to debug level 3.\n",
96+
" Return to debug level 2.\n",
97+
" Return to debug level 1.\n",
98+
" Abort thread.\n",
99+
"#<THREAD \"SHELL Thread\" native {4DAF9DCA}>: Debugger invoked on condition of type TYPE-ERROR\n",
100+
" The value #<JUPYTER::IOPUB-STREAM {6D3551E3}> is not of type TWO-WAY-STREAM.\n",
101+
" Return to debug level 9.\n",
102+
" Return to debug level 8.\n",
103+
" Return to debug level 7.\n",
104+
" Return to debug level 6.\n",
105+
" Return to debug level 5.\n",
106+
" Return to debug level 4.\n",
107+
" Return to debug level 3.\n",
108+
" Return to debug level 2.\n",
109+
" Return to debug level 1.\n",
110+
" Abort thread.\n"
56111
]
57112
}
58113
],
@@ -1571,17 +1626,17 @@
15711626
],
15721627
"metadata": {
15731628
"kernelspec": {
1574-
"display_name": "Common Lisp (SBCL)",
1629+
"display_name": "Common Lisp (Armed Bear Common Lisp)",
15751630
"language": "common-lisp",
1576-
"name": "common-lisp_sbcl"
1631+
"name": "common-lisp_abcl"
15771632
},
15781633
"language_info": {
15791634
"codemirror_mode": "text/x-common-lisp",
15801635
"file_extension": ".lisp",
15811636
"mimetype": "text/x-common-lisp",
15821637
"name": "common-lisp",
15831638
"pygments_lexer": "common-lisp",
1584-
"version": "2.1.1"
1639+
"version": "1.9.1-fasl43"
15851640
},
15861641
"widgets": {
15871642
"application/vnd.jupyter.widget-state+json": {

src/lab-extension/asdf.lisp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(in-package #:jupyter/lab-extension)
2+
3+
(defun extension-pathname (name)
4+
(merge-pathnames (make-pathname :directory (list :relative
5+
#+darwin "Jupyter"
6+
#-darwin "jupyter"
7+
"labextensions"
8+
name))
9+
#+darwin (merge-pathnames (make-pathname :directory '(:relative "Library"))
10+
(uiop:getenv-pathname "HOME" :ensure-directory t))
11+
#+windows (uiop:get-folder-path :appdata)
12+
#-(or darwin windows) (uiop:xdg-data-home)))
13+
14+
(defclass jupyter-lab-extension (asdf:file-component)
15+
()
16+
(:default-initargs :type "lab-extension"))
17+
18+
(defmethod asdf:input-files ((op asdf:compile-op) (c jupyter-lab-extension))
19+
(remove-if (lambda (x)
20+
(not (uiop:file-pathname-p x)))
21+
(directory (merge-pathnames (make-pathname :directory '(:relative :wild-inferiors)
22+
:name :wild :type :wild :version :wild)
23+
(asdf:component-pathname c)))))
24+
25+
(defmethod asdf:output-files ((op asdf:compile-op) (c jupyter-lab-extension))
26+
(values (loop with source = (asdf:component-pathname c)
27+
with destination = (extension-pathname (asdf:component-name c))
28+
29+
for x in (directory (merge-pathnames (make-pathname :directory '(:relative :wild-inferiors)
30+
:name :wild :type :wild :version :wild)
31+
source))
32+
when (uiop:file-pathname-p x)
33+
collect (merge-pathnames (uiop:subpathp x source) destination))
34+
t))
35+
36+
(defmethod asdf:perform ((op asdf:compile-op) (c jupyter-lab-extension))
37+
(loop for input in (asdf:input-files op c)
38+
for output in (asdf:output-files op c)
39+
do (ensure-directories-exist output)
40+
(uiop:copy-file input output)))
41+
42+
(defmethod asdf:perform ((op asdf:load-op) (c jupyter-lab-extension)))
43+
44+
(setf (find-class 'asdf::jupyter-lab-extension) (find-class 'jupyter-lab-extension))

src/lab-extension/packages.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(defpackage #:jupyter/lab-extension
2+
(:use #:common-lisp)
3+
(:export #:jupyter-lab-extension))

src/utils.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
(defmacro hash-case (form &rest clauses)
140140
(let ((ev-form (gensym))
141141
(hash-form (gensym)))
142-
(if (< (length clauses) 5)
142+
(if (or (< (length clauses) 5) #+abcl t #-abcl nil)
143143
`(let ((,ev-form ,form))
144144
(cond
145145
,@(mapcar (lambda (clause)

0 commit comments

Comments
 (0)