abingham / traad

An JSON+HTTP server for the rope Python refactoring library
MIT License
107 stars 20 forks source link

FYI I made virtualenv wrapper for Emacs Lisp. It could help Traad installation problems. #50

Closed tkf closed 11 years ago

tkf commented 11 years ago

I made virtualenv wrapper for Emacs Lisp to help installation of Emacs packages relying on Python modules: python-environment.el. I think it would help Traad installation.

You can just define a command like the following so that user can just do M-x traad-make-env to setup Python side of Traad.

(defun traad-make-env ()
  (interactive)
  (python-environment-run (list "pip" "install" traad-path-to-source)))

I am requesting for comment before fixing the API. If you are interested, please come in: https://github.com/tkf/emacs-python-environment/issues/1

abingham commented 11 years ago

Oh, very cool! I'll check it out when I get a chance. I'll also add a link or howto to the traad project site.

Austin

On Mon, Jun 24, 2013 at 12:35 PM, Takafumi Arakaki <notifications@github.com

wrote:

I made virtualenv wrapper for Emacs Lisp to help installation of Emacs packages relying on Python modules: python-environment.elhttps://github.com/tkf/emacs-python-environment. I think it would help Traad installation.

You can just define a command like the following so that user can just do M-x traad-make-env to setup Python side of Traad.

(defun traad-make-env () (interactive) (python-environment-run (list "pip" "install" traad-path-to-source)))

I am requesting for comment before fixing the API. If you are interested, please come in: tkf/emacs-python-environment#1https://github.com/tkf/emacs-python-environment/issues/1

— Reply to this email directly or view it on GitHubhttps://github.com/abingham/traad/issues/50 .

tkf commented 11 years ago

I'm glad that you are interested in. Well, unfortunately it is not as simple as putting it in README. You also need to set traad-server-program using (python-environment-bin "traad"). So you need to edit traad.el a little bit.

abingham commented 11 years ago

I don't think I want to make python-environment a hard requirement for traad, so what I was imagining is that I could tell people how to use python-environment and traad together if they wanted. Surely they can set traad-server-program in their configuration without me needing to modify traad.el, right?

Austin

On Mon, Jun 24, 2013 at 9:55 PM, Takafumi Arakaki notifications@github.comwrote:

I'm glad that you are interested in. Well, unfortunately it is not as simple as putting it in README. You also need to set traad-server-programusing (python-environment-bin "traad"). So you need to edit traad.el a little bit.

— Reply to this email directly or view it on GitHubhttps://github.com/abingham/traad/issues/50#issuecomment-19931346 .

tkf commented 11 years ago

Yes of course. But there are a few edge cases (e.g., python-environment-bin returns nil when traad is not installed) and people will need to take their time to see what is happening unless you write very well documentation (still they waste their time reading the doc). I think it's just you waste your time to edit a few lines of code or many people waste their time editing and debugging their configuration. I believe uninteresting thing like dependency resolution should be done behind the scenes.

If you don't like hard dependency, you can make python-environment.el as a soft dependency. You can define command above and call require inside of the command instead of the top-level of traad.el. You may need a bit of coding for the default traad-server-program also.

tkf commented 11 years ago

I saw you added a note on python-environment.el. I think people can use my library whatever they like as it is a free software, but note that this is not the intended usecase. My intention was to make one easy way to setup Python environment for Emacs, not add another hard-to-setup one, as I thought:

% python -m this | grep 'only one'
There should be one-- and preferably only one --obvious way to do it.

That's just my two cents.

abingham commented 11 years ago

I tried integrating python-environment into traad in some way that made sense for me, but I just couldn't do it comfortably. For example, I regularly need to switch between python2 and python3, both system installations and virtual environments. I also need this to work across work and home machines. In the end it was just simpler for me to manage virtual environments manually than to try to bake it into my emacs configuration...separation of concerns and so forth.

In the event that users of traad find common patterns with python-environment, then I'll be happy to consider building it in. I don't have a problem with it, and I'm sure it helps with certain workflows and environments, but just not for me. In fact it may just be that I work in a weird way, and maybe I'll learn something new. On that note, if you want to submit a patch or something more concrete for integrating traad with python-environment, I'm more than happy to consider it.

Austin

On Fri, Jul 5, 2013 at 4:58 PM, Takafumi Arakaki notifications@github.comwrote:

I saw you added a note on python-environment.el. I think people can use my library whatever they like as it is a free software, but note that this is not the intended usecase. My intention was to make one easy way to setup Python environment for Emacs, not add another hard-to-setup one, as I thought:

% python -m this | grep 'only one' There should be one-- and preferably only one --obvious way to do it.

That's just my two cents.

— Reply to this email directly or view it on GitHubhttps://github.com/abingham/traad/issues/50#issuecomment-20523111 .

tkf commented 11 years ago

switch between python2 and python3

You can have any number of virtualenv using python-environment.el. You just have to define a root directory and a corresponding virtualenv command. It could be something like ~/.emacs.d/traad-env/pyXY like the one in tox.

Re: patch. I am working on (pythonista.el)[https://github.com/tkf/emacs-pythonista] to setup everything you need for Python environment in Emacs. Current situation for Python programmer is not ideal because you need to install many packages and put them together by yourself. My goal is to install everything by M-x package-install pythonista and setup everything by just (require 'pythonista). I am still not sure about whether to use ropemacs or traad. (If I am going to use traad I think it worth implementing it.) I've never seriously compare ropemacs and traad and I don't find any "vs ropemacs" in README. Can you describe some pros and cons? It would be nice to see these things in README.

abingham commented 11 years ago

Traad vs. ropemacs is not an easy question. All I can say is that I tried using ropemacs several times, and never with much success. The problem as I recall was not to do with ropemacs itself, but with pymacs. I could never get pymacs to behave sensibly with multiple python versions and across environments. Even when I thought I had it working, it would stop working for mysterious reasons. A lot of this may have been user error, but in the end I spent many hours trying to get it working with nothing to show for it.

Also, the design of pymacs strikes me as weird. As I understand it, it translates between elisp and python, relying on a separate Python process, pipes, etc. It feels awkward. So, because of that, and because I thought it would be fun to write a tool myself, I wrote traad.

The short answer, then, is that I don't know if traad is necessarily better or worse than ropemacs. Ropemacs is probably better supported, tested, etc. than traad. For the most part, since I get very little feedback from users, I just treat traad as my own private tool. If it ever gets bigger, I'll probably change that attitude.

You'll need to evaluate the tools on their merits and decide which one fits better into the design of pythonista (which I'm looking forward to, by the way.) If you have any questions about traad, I'll of course be happy to answer them. You're an incredibly energetic emacs developer, and I want to support what you're doing!

Austin

On Fri, Jul 5, 2013 at 7:29 PM, Takafumi Arakaki notifications@github.comwrote:

switch between python2 and python3

You can have any number of virtualenv using python-environment.el. You just have to define a root directory and a corresponding virtualenv command. It could be something like ~/.emacs.d/traad-env/pyXY like the one in tox.

Re: patch. I am working on (pythonista.el)[ https://github.com/tkf/emacs-pythonista] to setup everything you need for Python environment in Emacs. Current situation for Python programmer is not ideal because you need to install many packages and put them together by yourself. My goal is to install everything by M-x package-install pythonista and setup everything by just (require 'pythonista). I am still not sure about whether to use ropemacs or traad. (If I am going to use traad I think it worth implementing it.) I've never seriously compare ropemacs and traad and I don't find any "vs ropemacs" in README. Can you describe some pros and cons? It would be nice to see these things in README.

— Reply to this email directly or view it on GitHubhttps://github.com/abingham/traad/issues/50#issuecomment-20530190 .

tkf commented 11 years ago

I could never get pymacs to behave sensibly with multiple python versions and across environments.

I think this is a good point. From what I know, I think using several Python versions with Pymacs requires you to install different build of Pymacs (because you need to "compile" Pymacs Python module) and use it with different Emacs processes. But why do you need to use rope with different Python version? Can't Pymacs run with Python 2.7 treat Python 3.3 source code?

abingham commented 11 years ago

As far as I can tell, the version of Python running rope needs to match the version of Python syntax in the file you're refactoring. I ran a few experiments to try to verify this a year or so ago, and it certainly seemed to be true. It may be that rope is actually smarter than that now, or that I wasn't using rope properly.

It's worth investigating this a bit more, but I honestly don't have much time for that right now. I just started a new company, and I'm up to my eyeballs in work!

Austin

On Sun, Jul 7, 2013 at 2:27 PM, Takafumi Arakaki notifications@github.comwrote:

I could never get pymacs to behave sensibly with multiple python versions and across environments.

I think this is a good point. From what I know, I think using several Python versions with Pymacs requires you to install different build of Pymacs (because you need to "compile" Pymacs Python module) and use it with different Emacs processes. But why do you need to use rope with different Python version? Can't Pymacs run with Python 2.7 treat Python 3.3 source code?

— Reply to this email directly or view it on GitHubhttps://github.com/abingham/traad/issues/50#issuecomment-20570008 .

tkf commented 11 years ago

That's informative. Thanks. I'll let you know when I make some progress around python-environment.el stuff. And good luck with your new company :)