refactor!(org): remove ob-ipython
BREAKING CHANGE: This commit removes the ob-ipython package; it's been deprecated for some time because the upstream package is no longer maintained and is broken on most, common versions of Python anyway. Jupyter is a superior alternative, in any case.
This commit is contained in:
parent
d81f1862f7
commit
b7954f927f
5 changed files with 4 additions and 202 deletions
|
@ -19,8 +19,8 @@ intuitive out of the box:
|
||||||
org files to reveal.js slideshows.
|
org files to reveal.js slideshows.
|
||||||
- Drag-and-drop support for images (with inline preview) and media files (drops
|
- Drag-and-drop support for images (with inline preview) and media files (drops
|
||||||
a file icon and a short link) (requires [[doom-module:+dragndrop]] flag).
|
a file icon and a short link) (requires [[doom-module:+dragndrop]] flag).
|
||||||
- Integration with pandoc, ipython, jupyter, reveal.js, beamer, and others
|
- Integration with pandoc, jupyter, reveal.js, beamer, and others (requires
|
||||||
(requires flags).
|
flags).
|
||||||
- Export-to-clipboard functionality, for copying text into formatted html,
|
- Export-to-clipboard functionality, for copying text into formatted html,
|
||||||
markdown or rich text to the clipboard (see fn:+org/export-to-clipboard and
|
markdown or rich text to the clipboard (see fn:+org/export-to-clipboard and
|
||||||
fn:+org/export-to-clipboard-as-rich-text).
|
fn:+org/export-to-clipboard-as-rich-text).
|
||||||
|
@ -58,8 +58,6 @@ https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode
|
||||||
- +hugo ::
|
- +hugo ::
|
||||||
Enable integration with [[https://gohugo.io][hugo]] to export from Emacs well-formed ([[https://github.com/russross/blackfriday][blackfriday]])
|
Enable integration with [[https://gohugo.io][hugo]] to export from Emacs well-formed ([[https://github.com/russross/blackfriday][blackfriday]])
|
||||||
markdown.
|
markdown.
|
||||||
- +ipython ::
|
|
||||||
(**DEPRECATED**) Enable ipython integration for babel.
|
|
||||||
- +journal ::
|
- +journal ::
|
||||||
Enable [[doom-package:org-journal]] integration.
|
Enable [[doom-package:org-journal]] integration.
|
||||||
- +jupyter ::
|
- +jupyter ::
|
||||||
|
@ -95,7 +93,6 @@ https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode
|
||||||
- [[doom-package:ob-async]]
|
- [[doom-package:ob-async]]
|
||||||
- [[doom-package:ob-crystal]] if [[doom-module::lang crystal]]
|
- [[doom-package:ob-crystal]] if [[doom-module::lang crystal]]
|
||||||
- [[doom-package:ob-go]] if [[doom-module::lang go]]
|
- [[doom-package:ob-go]] if [[doom-module::lang go]]
|
||||||
- [[doom-package:ob-ipython]] if [[doom-module:+ipython]]
|
|
||||||
- [[doom-package:ob-nim]] if [[doom-module::lang nim]]
|
- [[doom-package:ob-nim]] if [[doom-module::lang nim]]
|
||||||
- [[doom-package:ob-racket]] if [[doom-module::lang racket]]
|
- [[doom-package:ob-racket]] if [[doom-module::lang racket]]
|
||||||
- [[doom-package:ob-restclient]] if [[doom-module::lang rest]]
|
- [[doom-package:ob-restclient]] if [[doom-module::lang rest]]
|
||||||
|
|
|
@ -1,152 +0,0 @@
|
||||||
;;; lang/org/autoload/contrib-ipython.el -*- lexical-binding: t; -*-
|
|
||||||
;;;###if (modulep! +ipython)
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +org-ob-ipython-initiate-session-a (&optional session params)
|
|
||||||
"Create a session named SESSION according to PARAMS."
|
|
||||||
(if (string= session "none")
|
|
||||||
(error
|
|
||||||
"ob-ipython currently only supports evaluation using a session.
|
|
||||||
Make sure your src block has a :session param.")
|
|
||||||
(when (not (string-suffix-p ".json" session t))
|
|
||||||
(ob-ipython--create-kernel
|
|
||||||
(ob-ipython--normalize-session
|
|
||||||
session)
|
|
||||||
(cdr (assoc :kernel params))))
|
|
||||||
(ob-ipython--create-repl
|
|
||||||
(ob-ipython--normalize-session
|
|
||||||
session)
|
|
||||||
params)))
|
|
||||||
|
|
||||||
(defun +org--ob-ipython-generate-local-path-from-remote (session host params)
|
|
||||||
"Given a remote SESSION with PARAMS and corresponding HOST, copy remote config to local, start a jupyter console to generate a new one."
|
|
||||||
(let* ((runtime-dir
|
|
||||||
(cdr
|
|
||||||
(doom-call-process "ssh " host "jupyter" "--runtime-dir")))
|
|
||||||
(runtime-file (concat runtime-dir "/" "kernel-" session ".json"))
|
|
||||||
(tramp-path (concat "/ssh:" host ":" runtime-file))
|
|
||||||
(tramp-copy (concat (or +ob-ipython-local-runtime-dir
|
|
||||||
(cdr (doom-call-process "jupyter" "--runtime-dir")))
|
|
||||||
"/remote-" host "-kernel-" session ".json"))
|
|
||||||
(local-path
|
|
||||||
(concat
|
|
||||||
"Python:ob-ipython-"
|
|
||||||
(file-name-sans-extension (file-name-nondirectory tramp-copy))
|
|
||||||
"-ssh.json")))
|
|
||||||
;; scp remote file to local
|
|
||||||
(copy-file tramp-path tramp-copy t)
|
|
||||||
;; connect to remote use new config
|
|
||||||
(let* ((python-shell-interpreter-interactive-arg " console --simple-prompt")
|
|
||||||
(python-shell-prompt-detect-enabled nil)
|
|
||||||
(python-shell-completion-native-enable nil)
|
|
||||||
(buf (python-shell-make-comint
|
|
||||||
(concat ob-ipython-command
|
|
||||||
" console --simple-prompt --existing "
|
|
||||||
tramp-copy " --ssh " host)
|
|
||||||
(concat "" local-path)
|
|
||||||
t))
|
|
||||||
(proc (get-buffer-process buf))
|
|
||||||
(dir (cdr (assoc :pydir params))))
|
|
||||||
(sleep-for 3)
|
|
||||||
(when dir
|
|
||||||
(with-current-buffer buf
|
|
||||||
(setq-local default-directory dir)))
|
|
||||||
(format "*%s*" proc))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +org-ob-ipython-create-repl-a (name &optional params)
|
|
||||||
"Create repl based on NAME and PARAMS.
|
|
||||||
If PARAMS specifies remote kernel, copy the kernel config from remote server and
|
|
||||||
create a repl connecting to remote session."
|
|
||||||
(let ((cmd (string-join (ob-ipython--kernel-repl-cmd name) " ")))
|
|
||||||
(cond ((string= "default" name)
|
|
||||||
(run-python cmd nil nil)
|
|
||||||
(format "*%s*" python-shell-buffer-name))
|
|
||||||
((string-match "^remote-.*ssh.json" name)
|
|
||||||
(when (not (ignore-errors
|
|
||||||
(process-live-p
|
|
||||||
(get-process
|
|
||||||
(format
|
|
||||||
"Python:ob-ipython-%s"
|
|
||||||
name)))))
|
|
||||||
(let* ((remote (s-split "-" name))
|
|
||||||
(remote-host (nth 1 remote))
|
|
||||||
(remote-session (nth 3 remote)))
|
|
||||||
(+org--ob-ipython-generate-local-path-from-remote
|
|
||||||
remote-session
|
|
||||||
remote-host
|
|
||||||
params))))
|
|
||||||
((let* ((process-name (format "Python:ob-ipython-%s" name))
|
|
||||||
(python-shell-prompt-detect-enabled nil)
|
|
||||||
(python-shell-completion-native-enable nil)
|
|
||||||
(buf (python-shell-make-comint cmd process-name t))
|
|
||||||
(dir (cdr (assoc :pydir params))))
|
|
||||||
(if dir
|
|
||||||
(with-current-buffer buf
|
|
||||||
(setq-local default-directory dir)))
|
|
||||||
(sleep-for 1)
|
|
||||||
(format "*%s*" process-name))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +org-babel-execute:ipython-a (body params)
|
|
||||||
"Execute a BODY of IPython code with PARAMS in org-babel.
|
|
||||||
This function is called by `org-babel-execute-src-block'."
|
|
||||||
(message default-directory)
|
|
||||||
(org-babel-ipython-initiate-session (cdr (assoc :session params))
|
|
||||||
params))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; * org-src-edit
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +org-babel-edit-prep:ipython-a (info)
|
|
||||||
(let* ((params (nth 2 info))
|
|
||||||
(session (cdr (assoc :session params))))
|
|
||||||
(org-babel-ipython-initiate-session session params))
|
|
||||||
;; Support for python.el's "send-code" commands within edit buffers.
|
|
||||||
(setq-local python-shell-buffer-name
|
|
||||||
(format "Python:ob-ipython-%s"
|
|
||||||
(ob-ipython--normalize-session
|
|
||||||
(cdr (assoc :session (nth 2 info))))))
|
|
||||||
(setq-local default-directory
|
|
||||||
(format "%s"
|
|
||||||
(ob-ipython--normalize-session
|
|
||||||
(cdr (assoc :pydir (nth 2 info))))))
|
|
||||||
(ob-ipython-mode 1)
|
|
||||||
;; hack on company mode to use company-capf rather than company-anaconda
|
|
||||||
(when (modulep! :completion company)
|
|
||||||
(setq-local company-backends
|
|
||||||
'(company-capf
|
|
||||||
company-dabbrev
|
|
||||||
company-files
|
|
||||||
company-yasnippet))
|
|
||||||
(setq-local company-idle-delay nil))
|
|
||||||
(when (featurep 'lpy)
|
|
||||||
(setq lispy-python-proc
|
|
||||||
(format "Python:ob-ipython-%s"
|
|
||||||
(ob-ipython--normalize-session
|
|
||||||
(cdr (assoc :session (nth 2 info)))))
|
|
||||||
lispy--python-middleware-loaded-p nil)
|
|
||||||
(lispy--python-middleware-load)))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; * retina
|
|
||||||
|
|
||||||
(defun +org--ob-ipython-mac-2x-image-file-name (filename &optional scale)
|
|
||||||
"Return the name of high-resolution image file for FILENAME.
|
|
||||||
The optional arg SCALE is scale factor, and defaults to 2."
|
|
||||||
(let ((pos (or (string-match "\\.[^./]*\\'" filename) (length filename))))
|
|
||||||
(format "%s@%dx%s"
|
|
||||||
(substring filename 0 pos)
|
|
||||||
(or scale 2)
|
|
||||||
(substring filename pos))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +org-ob-ipython-write-base64-string-a (oldfunc &rest args)
|
|
||||||
(let ((file (car args))
|
|
||||||
(b64-string (cdr args)))
|
|
||||||
(let ((file2x (+org--ob-ipython-mac-2x-image-file-name file)))
|
|
||||||
(apply oldfunc file2x b64-string)
|
|
||||||
(shell-command (concat "convert " file2x " -resize 50% " file)))))
|
|
|
@ -289,8 +289,8 @@ Also adds support for a `:sync' parameter to override `:async'."
|
||||||
initialize)
|
initialize)
|
||||||
args))
|
args))
|
||||||
|
|
||||||
;; Refresh inline images after executing src blocks (useful for plantuml or
|
;; Refresh inline images after executing src blocks (useful for plantuml,
|
||||||
;; ipython, where the result could be an image)
|
;; where the result could be an image)
|
||||||
(add-hook! 'org-babel-after-execute-hook
|
(add-hook! 'org-babel-after-execute-hook
|
||||||
(defun +org-redisplay-inline-images-in-babel-result-h ()
|
(defun +org-redisplay-inline-images-in-babel-result-h ()
|
||||||
(unless (or
|
(unless (or
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
|
|
||||||
;;;###if (modulep! +ipython)
|
|
||||||
|
|
||||||
(use-package! ob-ipython
|
|
||||||
:defer t
|
|
||||||
:init
|
|
||||||
(defvar +ob-ipython-local-runtime-dir nil)
|
|
||||||
|
|
||||||
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
|
|
||||||
|
|
||||||
(add-hook! '+org-babel-load-functions
|
|
||||||
(defun +org-babel-load-ipython-h (lang)
|
|
||||||
(and (string-prefix-p "jupyter-" (symbol-name lang))
|
|
||||||
(require 'ob-ipython nil t))))
|
|
||||||
|
|
||||||
(after! org-src
|
|
||||||
(add-to-list 'org-src-lang-modes '("ipython" . python)))
|
|
||||||
(after! ox-latex
|
|
||||||
(add-to-list 'org-latex-minted-langs '(ipython "python")))
|
|
||||||
:config
|
|
||||||
(set-popup-rules!
|
|
||||||
'(("\\*ob-ipython.*"
|
|
||||||
:slot 2 :side right :size 100 :height 0.2
|
|
||||||
:select nil :quit nil :ttl nil)
|
|
||||||
("^ \\*Python"
|
|
||||||
:slot 0 :side right :size 100
|
|
||||||
:select nil :quit nil :ttl nil)))
|
|
||||||
|
|
||||||
;; advices for remote kernel and org-src-edit
|
|
||||||
(advice-add #'ob-ipython--create-repl :override #'+org-ob-ipython-create-repl-a)
|
|
||||||
(advice-add #'org-babel-edit-prep:ipython :override #'+org-babel-edit-prep:ipython-a)
|
|
||||||
(advice-add #'org-babel-execute:ipython :before #'+org-babel-execute:ipython-a)
|
|
||||||
(advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a)
|
|
||||||
|
|
||||||
;; retina resolution image hack
|
|
||||||
(when (featurep :system 'macos)
|
|
||||||
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
|
|
||||||
|
|
||||||
;; ipython has its own async keyword, disable ipython in ob-async.
|
|
||||||
(after! ob-async
|
|
||||||
(add-to-list 'ob-async-no-async-languages-alist "ipython")))
|
|
|
@ -78,8 +78,6 @@
|
||||||
(when (modulep! +gnuplot)
|
(when (modulep! +gnuplot)
|
||||||
(package! gnuplot :pin "7138b139d2dca9683f1a81325c643b2744aa1ea3")
|
(package! gnuplot :pin "7138b139d2dca9683f1a81325c643b2744aa1ea3")
|
||||||
(package! gnuplot-mode :pin "601f6392986f0cba332c87678d31ae0d0a496ce7"))
|
(package! gnuplot-mode :pin "601f6392986f0cba332c87678d31ae0d0a496ce7"))
|
||||||
(when (modulep! +ipython) ; DEPRECATED
|
|
||||||
(package! ob-ipython :pin "7147455230841744fb5b95dcbe03320313a77124"))
|
|
||||||
(when (modulep! +jupyter)
|
(when (modulep! +jupyter)
|
||||||
(package! jupyter :pin "b279c90295ed7ef89832d655cf8d9077233f1098"))
|
(package! jupyter :pin "b279c90295ed7ef89832d655cf8d9077233f1098"))
|
||||||
(when (modulep! +journal)
|
(when (modulep! +journal)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue