GNU bug report logs - #46345
27.1; Issue with `run-python' when `exec-path' is set buffer-locally

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Sat, 6 Feb 2021 13:05:01 UTC

Severity: normal

Found in version 27.1

Full log


View this message in rfc822 format

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: 46345 <at> debbugs.gnu.org
Subject: bug#46345: 27.1; Issue with `run-python' when `exec-path' is set buffer-locally
Date: Sat, 06 Feb 2021 12:18:10 +0100
It is reasonable to set `exec-path' locally in Python buffers to reflect
a virtualenv, so that the external tools invoked by Eglot, Flycheck,
etc., work correctly.

This leads to two issues with `run-python'.  First, it doesn't inherit
the buffer-local `exec-path', which is probably the correct behavior.
Second, just having a buffer-local `exec-path' breaks the mechanism that
uses `python-shell-virtualenv-root' to find the Python interpreter.
`process-environment' is likely affected by similar issues.

On a related note: is there a good reason for
`python-shell-calculate-process-environment' not to update the PATH
entry?  It's not inconceivable that a Python script needs to call a
program which is only available in the virtualenv.  Moreover, from the
end-user perspective, it would be convenient if adding a call to

    (setq-local process-environment (python-shell-calculate-process-environment))

in some hook would make tools like `M-x compile' follow the
`python-shell-virtualenv-root' settings.




This bug report was last modified 4 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.