diff --git a/cl-jupyter.lisp b/cl-jupyter.lisp index 4066ac5..46eaf1e 100644 --- a/cl-jupyter.lisp +++ b/cl-jupyter.lisp @@ -1,7 +1,11 @@ + + + ;; not yet installed in quicklisp directory (push (truename (format nil "~Asrc/" (directory-namestring *load-truename*))) asdf:*central-registry*) +#-ros.init (let ((cmd-args ;; Borrowed from apply-argv, command-line-arguments. Temporary solution (?) ;; This is not PvE's code. @@ -47,5 +51,9 @@ (in-package #:cl-jupyter-user) ;; start main loop +#-ros.init (cl-jupyter:kernel-start) +#+ros.init +(defun main (&rest argv) + (cl-jupyter:kernel-start argv)) diff --git a/install-cl-jupyter.py b/install-cl-jupyter.py index ba55f33..ea1bd62 100644 --- a/install-cl-jupyter.py +++ b/install-cl-jupyter.py @@ -199,6 +199,58 @@ def process_command_line(argv): raise RequirementException(message) print("... Kernel: using {}".format(sbcl_version_string)) +elif config.lisp_implementation == "roswell": + if not config.lisp_executable: + config.lisp_executable = 'ros' + try: + + sbcl_version_string = subprocess.check_output([config.lisp_executable, "-L", "sbcl-bin", "run", "--", "--version"]).decode() + except FileNotFoundError: + halt("Error: Lisp executable '{0}' not in PATH".format (config.lisp_executable)) + except subprocess.CalledProcessError as e: + halt("Error: {} from SBCL".format(e)) + + print("sbcl reports version {}".format(sbcl_version_string)) + + import re + try: + regexp = re.compile(r'(\d+)\.(\d+)\.(\d+)') + version = regexp.findall(sbcl_version_string)[0] + except IndexError: + halt("Error: issue with sbcl version string (please report)") + + config.sbcl_version = map(int, version) + + sbcl_min_version = (1, 2, 0) + for have, need in zip(config.sbcl_version, sbcl_min_version): + if have < need: + message = "found {}; required: sbcl >= {}" + message = message.format(config.sbcl_version, sbcl_min_version) + raise RequirementException(message) + + print("... Kernel: using {}".format(sbcl_version_string)) +elif config.lisp_implementation == "roswell-ccl": + if not config.lisp_executable: + config.lisp_executable = 'ros' + + try: + ccl_version_string = subprocess.check_output([config.lisp_executable, "-L", "ccl-bin", "run", "--","-V"]).decode() + except FileNotFoundError: + halt("Error: Lisp executable '{0}' not in PATH".format (config.lisp_executable)) + except subprocess.CalledProcessError as e: + halt("Error: {} from CCL".format(e)) + + import re + m = re.match(r".*[^0-9](([0-9]+\.)[0-9]+\.[0-9]+)", ccl_version_string) + if not m: + halt("Error: issue with ccl version string (please report)") + + config.ccl_version = tuple([int(d) for d in m.group(1).split(".")]) + #print("ccl version = {}".format(config.ccl_version)) + if config.ccl_version[0] < 1 or config.ccl_version[1] < 10: + halt("Error: require CCL v1.10 or above") + + print("... Kernel: using {}".format(ccl_version_string)) elif config.lisp_implementation == "ccl": if not config.lisp_executable: @@ -253,6 +305,26 @@ def process_command_line(argv): "display_name": "SBCL Lisp", "language": "lisp" } +elif config.lisp_implementation == "roswell": + KERNEL_SPEC = { + "argv": [ + config.lisp_executable, + '-L', 'sbcl-bin', + "{0}/cl-jupyter.lisp".format(config.cl_jupyter_startup_def_dir), + '{connection_file}'], + "display_name": "roswell", + "language": "lisp" + } +elif config.lisp_implementation == "roswell-ccl": + KERNEL_SPEC = { + "argv": [ + config.lisp_executable, + '-L', 'ccl-bin', + "{0}/cl-jupyter.lisp".format(config.cl_jupyter_startup_def_dir), + '{connection_file}'], + "display_name": "roswell-ccl", + "language": "lisp" + } elif config.lisp_implementation == "ccl": KERNEL_SPEC = { "argv": [ diff --git a/src/kernel.lisp b/src/kernel.lisp index e9218be..5799765 100644 --- a/src/kernel.lisp +++ b/src/kernel.lisp @@ -84,8 +84,8 @@ (signature-scheme :initarg :signature-scheme :reader config-signature-scheme :type string) (key :initarg :key :reader kernel-config-key))) -(defun kernel-start () - (let ((cmd-args (get-argv))) +(defun kernel-start (&optional args) + (let ((cmd-args (or args (get-argv)))) ;(princ (banner)) (write-line "") (format t "~A: an enhanced interactive Common Lisp REPL~%" +KERNEL-IMPLEMENTATION-NAME+)