@@ -1023,18 +1023,34 @@ Otherwise, fall back to Jedi (static)."
1023
1023
(setq lispy--python-middleware-loaded-p nil )
1024
1024
(lispy--python-middleware-load))
1025
1025
1026
+ (defun lispy--python-slurp (f )
1027
+ (with-temp-buffer
1028
+ (insert-file-contents f)
1029
+ (buffer-string )))
1030
+
1031
+ (defun lispy--python-setup-cmd ()
1032
+ (concat
1033
+ " from importlib.machinery import SourceFileLoader;"
1034
+ (format " lp=SourceFileLoader('lispy-python', '%s ').load_module(); "
1035
+ lispy--python-middleware-file)
1036
+ (format " lp.setup('%s ') " lispy--python-init-file)))
1037
+
1026
1038
(defun lispy--python-middleware-load ()
1027
1039
" Load the custom Python code in \" lispy-python.py\" ."
1028
1040
(unless lispy--python-middleware-loaded-p
1029
- (let ((default-directory (or (locate-dominating-file default-directory " .git" )
1030
- default-directory)))
1041
+ (let* ((default-directory (or (locate-dominating-file default-directory " .git" )
1042
+ default-directory))
1043
+ out)
1031
1044
; ; send single line so that python.el does no /tmp/*.py magic, which does not work in Docker
1032
- (lispy--eval-python-plain
1033
- (concat
1034
- " from importlib.machinery import SourceFileLoader;"
1035
- (format " lp=SourceFileLoader('lispy-python', '%s ').load_module(); "
1036
- lispy--python-middleware-file)
1037
- (format " lp.setup('%s ') " lispy--python-init-file)))
1045
+ (setq out (lispy--eval-python-plain (lispy--python-setup-cmd)))
1046
+ (when (string-match " FileNotFoundError" out)
1047
+ (let* ((text (lispy--python-slurp lispy--python-middleware-file))
1048
+ (ben (replace-regexp-in-string " \n " " " (base64-encode-string text)))
1049
+ (setup-cmd (let ((lispy--python-middleware-file " /tmp/lispy.py" ))
1050
+ (lispy--python-setup-cmd))))
1051
+ (lispy--eval-python-plain
1052
+ (format " import base64; open('/tmp/lispy.py','w').write(base64.b64decode('%s ').decode()); %s "
1053
+ ben setup-cmd))))
1038
1054
(setq lispy--python-middleware-loaded-p t ))))
1039
1055
1040
1056
(defun lispy--python-arglist (symbol filename line column )
0 commit comments