Skip to content

Commit 17f4796

Browse files
committed
Set path property for remote pythonic processes.
1 parent de020bc commit 17f4796

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

pythonic.el

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ It will use `python-shell-exec-path' for PATH variable,
120120
(--remove (member it python-shell-extra-pythonpaths) it)
121121
(append python-shell-extra-pythonpaths it)))))))
122122

123+
(defun pythonic-get-path ()
124+
"Return appropriate PATH variable for pythonic process."
125+
(if (pythonic-remote-p)
126+
(pythonic-get-path-variable-tramp)
127+
(pythonic-get-path-variable)))
128+
123129
(defun pythonic-get-path-variable ()
124130
"Get PATH variable according to `python-shell-exec-path'."
125131
(s-join path-separator
@@ -129,14 +135,20 @@ It will use `python-shell-exec-path' for PATH variable,
129135
(-remove 's-blank?)
130136
(-distinct))))
131137

138+
(defun pythonic-get-path-variable-tramp ()
139+
"Get PATH variable on remote host according to `python-shell-exec-path'."
140+
(let* ((vec (tramp-dissect-file-name (pythonic-tramp-connection)))
141+
(path (-distinct (append python-shell-exec-path (tramp-get-remote-path vec)))))
142+
(s-join path-separator path)))
143+
132144
(defun pythonic-set-path-variable ()
133145
"Set PATH according to `python-shell-exec-path'."
134146
(setenv "PATH" (pythonic-get-path-variable)))
135147

136148
(defun pythonic-set-path-variable-tramp ()
137149
"Set PATH according to `python-shell-exec-path' on remote host."
138150
(let* ((vec (tramp-dissect-file-name (pythonic-tramp-connection)))
139-
(path (append python-shell-exec-path (tramp-get-remote-path vec))))
151+
(path (s-split path-separator (pythonic-get-path-variable-tramp))))
140152
(tramp-set-connection-property vec "remote-path" path)
141153
(tramp-set-remote-path vec)))
142154

@@ -186,7 +198,7 @@ process flag."
186198
(set-process-query-on-exit-flag process query-on-exit)
187199
(process-put process 'default-directory default-directory)
188200
(process-put process 'environment python-shell-process-environment)
189-
(process-put process 'path (pythonic-get-path-variable))
201+
(process-put process 'path (pythonic-get-path))
190202
(process-put process 'pythonpath (pythonic-get-pythonpath-variable))
191203
process)))
192204

test/pythonic-test.el

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,20 @@ remote host."
316316
(start-pythonic :process "out" :args '("-V"))
317317
'path)))))
318318

319+
(ert-deftest test-start-pythonic-path-property-tramp ()
320+
"Set `python-shell-exec-path' as `path' process property on remote process."
321+
(unwind-protect
322+
(let* ((python-shell-interpreter "/ssh:test@localhost:/path/to/the/python")
323+
(home (f-expand "~"))
324+
(python-shell-exec-path '("/home/test/bin")))
325+
(should (equal "/home/test/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
326+
(process-get
327+
(start-pythonic :process "out" :args '("-V"))
328+
'path))))
329+
(kill-buffer "*tramp/ssh test@localhost*")
330+
(setq tramp-current-connection)
331+
(sleep-for 0.5)))
332+
319333
(ert-deftest test-start-pythonic-pythonpath-property ()
320334
"Set `python-shell-extra-pythonpaths' as `pythonpath' process property."
321335
(let* ((home (f-expand "~"))

0 commit comments

Comments
 (0)