@@ -90,6 +90,12 @@ It will use `python-shell-exec-path' for PATH variable,
9090 (pythonic-set-path-variable)
9191 (pythonic-set-extra-variables)))
9292
93+ (defun pythonic-get-pythonpath ()
94+ " Get appropriate PYTHONPATH variable for pythonic process."
95+ (if (pythonic-remote-p)
96+ (pythonic-get-pythonpath-variable-tramp)
97+ (pythonic-get-pythonpath-variable)))
98+
9399(defun pythonic-get-pythonpath-variable ()
94100 " Get PYTHONPATH variable from `python-shell-extra-pythonpaths' variable."
95101 (s-join path-separator
@@ -99,26 +105,30 @@ It will use `python-shell-exec-path' for PATH variable,
99105 (-remove 's-blank? )
100106 (-distinct))))
101107
108+ (defun pythonic-get-pythonpath-variable-tramp ()
109+ " Get PYTHONPATH variable form `python-shell-extra-pythonpaths' on the remote host."
110+ (let ((connection (tramp-dissect-file-name (pythonic-tramp-connection))))
111+ (s-join path-separator
112+ (--> (progn
113+ (tramp-send-command connection " echo $PYTHONPATH" )
114+ (with-current-buffer (tramp-get-connection-buffer connection)
115+ (buffer-string )))
116+ (s-trim it)
117+ (s-split " :" it t )
118+ (--remove (member it python-shell-extra-pythonpaths) it)
119+ (append python-shell-extra-pythonpaths it)))))
120+
102121(defun pythonic-set-pythonpath-variable ()
103122 " Set PYTHONPATH variable from `python-shell-extra-pythonpaths' variable."
104123 (setenv " PYTHONPATH" (pythonic-get-pythonpath-variable)))
105124
106125(defun pythonic-set-pythonpath-variable-tramp ()
107126 " Set PYTHONPATH variable from `python-shell-extra-pythonpaths' variable on remote host."
108- (let ((connection (tramp-dissect-file-name (pythonic-tramp-connection))))
109- (tramp-send-command
110- connection
111- (format
112- " export PYTHONPATH=%s"
113- (s-join " :"
114- (--> (progn
115- (tramp-send-command connection " echo $PYTHONPATH" )
116- (with-current-buffer (tramp-get-connection-buffer connection)
117- (buffer-string )))
118- (s-trim it)
119- (s-split " :" it t )
120- (--remove (member it python-shell-extra-pythonpaths) it)
121- (append python-shell-extra-pythonpaths it)))))))
127+ (tramp-send-command
128+ (tramp-dissect-file-name (pythonic-tramp-connection))
129+ (format
130+ " export PYTHONPATH=%s"
131+ (pythonic-get-pythonpath-variable-tramp))))
122132
123133(defun pythonic-get-path ()
124134 " Return appropriate PATH variable for pythonic process."
@@ -199,7 +209,7 @@ process flag."
199209 (process-put process 'default-directory default-directory)
200210 (process-put process 'environment python-shell-process-environment)
201211 (process-put process 'path (pythonic-get-path))
202- (process-put process 'pythonpath (pythonic-get-pythonpath-variable ))
212+ (process-put process 'pythonpath (pythonic-get-pythonpath))
203213 process)))
204214
205215;;;### autoload
0 commit comments