unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Managing environments (Python venv, guix environment, etc.)
@ 2016-07-14 21:36 sbaugh
  2016-07-15 16:26 ` Stefan Monnier
  0 siblings, 1 reply; 59+ messages in thread
From: sbaugh @ 2016-07-14 21:36 UTC (permalink / raw)
  To: emacs-devel


Hi emacs-devel,

There are a number of tools which create a reproducible working
environment for projects by changing environment variables such as PATH
and LIBRARY_PATH to point at project-specific directories containing
project-specific versions of libraries and executables. Two examples
among many: Python's "virtualenv" and Guix's "guix environment".

A typical shell-based workflow with these tools would involve starting
your shell and activating the tool so it mutates your environment and
puts you into the working environment specific to that project. With
multiple terminals, one can have multiple shells open at the same time
to work on multiple different projects each with a different
environment.

One could run several Emacs processes with different environments to
work on different projects, but that's very painful. So I'm trying to
teach Emacs how to handle multiple environments within the same
process. Currently, Emacs can only operate in one environment at a time,
since exec-path and process-environment are single global variables that
are referenced directly by many different Elisp functions.

Here's the ideal: The recently added support for projects in project.el
is augmented to also know about the environment of those projects. When
compile, async-shell-command, etc., are invoked in a buffer belonging to
a project, the executed process is run with the environment defined for
that project. Any other Elisp functions that inspect the environment
should reference the environment defined for the current project.

But I would count it as a failure if multiple-environment support
required every Elisp package that runs processes to be explicitly
modified to support it. Even just modifying everything in Emacs itself
would be a major undertaking. So backwards-compatibility through some
clever hacks is important.

But I am only a humble novice, and am unsure about the best way to
achieve this. Here are a few ideas I had:

- Make exec-path and process-environment buffer-local

  I am told that this will cause a lot of bizarre behavior. In
  particular, I understand that this won't work with M-x compile, which
  reuses another buffer to run the compilation.

- Make exec-path and process-environment a different kind of
  buffer-local dynamic variable

  The behavior of this variable would be that when it is defined locally
  in the current buffer, it behaves like a normal dynamic variable. And
  when it is not defined locally in the current buffer, looking up the
  variable will look up the variable dynamically instead of looking for
  a global value set with setq-default.
  This would mean that when M-x compile is invoked from some buffer, if
  exec-path and process-environment are not buffer-local in the compile
  buffer, those variables will be looked up dynamically, and found in
  the buffer-locals of the buffer that was current at the time of the
  M-x compile invocation.
  I don't know if this is possible given the implementation of dynamic
  variables in Emacs Lisp.

- Use the same functionality as TRAMP, somehow

  TRAMP supports transparently running processes in multiple arbitrary
  environments (usually ones accessible over the network, but local
  environments should work too).
  But I'm not really familiar with how TRAMP works, so I'm not sure if
  it's possible to make use of its process-running capabilities without
  using magic filenames, and without copying files back and forth (an
  ugly overhead in this case since the files would all be local).

- Use dir-locals

  I'm not sure how this could work, given the problems with making
  exec-path and process-environment buffer-local, but including it to be
  complete.

If any of the great masters have suggestions about how to achieve this,
I would greatly appreciate it. Thanks.




^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: Managing environments (Python venv, guix environment, etc.)
@ 2016-07-28 10:01 Spencer Baugh
  0 siblings, 0 replies; 59+ messages in thread
From: Spencer Baugh @ 2016-07-28 10:01 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

[-- Attachment #1: Type: text/html, Size: 965 bytes --]

^ permalink raw reply	[flat|nested] 59+ messages in thread
[parent not found: <87shuuvzz6.fsf@totally-fudged-out-message-id>]

end of thread, other threads:[~2016-07-30 16:17 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14 21:36 Managing environments (Python venv, guix environment, etc.) sbaugh
2016-07-15 16:26 ` Stefan Monnier
2016-07-17 22:41   ` sbaugh
2016-07-18 10:15     ` Andreas Röhler
2016-07-18 14:46     ` Stefan Monnier
2016-07-18 19:13       ` sbaugh
2016-07-19 13:39         ` Stefan Monnier
2016-07-24  3:35         ` Dmitry Gutov
2016-07-24  8:25           ` sbaugh
2016-07-24 23:08             ` Dmitry Gutov
2016-07-21  0:32       ` sbaugh
2016-07-22 20:19         ` Stefan Monnier
2016-07-23  7:10           ` Eli Zaretskii
2016-07-24  3:26             ` Dmitry Gutov
2016-07-24  8:25               ` sbaugh
2016-07-24 14:28                 ` Eli Zaretskii
2016-07-24 17:45                   ` sbaugh
2016-07-24 17:58                     ` Eli Zaretskii
2016-07-24 19:05                       ` Spencer Baugh
2016-07-24 19:36                         ` Eli Zaretskii
2016-07-25  4:50                           ` sbaugh
2016-07-25 17:04                             ` Eli Zaretskii
2016-07-28  0:47                               ` sbaugh
2016-07-24 23:04                 ` Dmitry Gutov
2016-07-25  2:37                   ` Eli Zaretskii
2016-07-25  5:01                     ` sbaugh
2016-07-25 17:06                       ` Eli Zaretskii
2016-07-25  7:07                   ` Michael Albinus
2016-07-25 12:49                     ` Dmitry Gutov
2016-07-25 13:03                       ` Michael Albinus
2016-07-25 13:06                         ` Dmitry Gutov
2016-07-25 13:41                         ` Stefan Monnier
2016-07-28  0:02                         ` sbaugh
2016-07-28  9:34                           ` Michael Albinus
2016-07-28 14:42                           ` Eli Zaretskii
2016-07-29 17:59                             ` sbaugh
2016-07-29 18:59                               ` Eli Zaretskii
2016-07-29 19:20                                 ` Stefan Monnier
2016-07-30  6:57                                   ` Eli Zaretskii
2016-07-30 14:42                                     ` Stefan Monnier
2016-07-30 15:56                                       ` Eli Zaretskii
2016-07-29 20:57                                 ` sbaugh
2016-07-30  7:34                                   ` Eli Zaretskii
2016-07-30 13:30                                     ` sbaugh
2016-07-30 16:17                                       ` Eli Zaretskii
2016-07-30 11:24                                   ` Michael Albinus
2016-07-29 18:42                           ` Stefan Monnier
2016-07-29 19:03                             ` Eli Zaretskii
2016-07-26  2:36                   ` Stefan Monnier
2016-07-24 14:24               ` Eli Zaretskii
2016-07-25  0:05                 ` Dmitry Gutov
2016-07-25 17:00                   ` Eli Zaretskii
2016-07-26  2:08                     ` Dmitry Gutov
2016-07-26  3:06                       ` Stefan Monnier
2016-07-26 10:45                         ` Michael Albinus
2016-07-26 12:46                           ` Stefan Monnier
2016-07-26 14:49                       ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2016-07-28 10:01 Spencer Baugh
     [not found] <87shuuvzz6.fsf@totally-fudged-out-message-id>
2016-07-28 10:08 ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).