Use python-environment.el to call virtualenv directly from Emacs #72

Merged
merged 23 commits into from Mar 10, 2014

Conversation

Projects
None yet
7 participants
@tkf
Owner

tkf commented Jun 22, 2013

... so that there is no Makefile compatible problem anymore (see #70).

See the comment below for more info.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

The purpose of this patch is to drop make dependencies, which caused some troubles in the past (see #11 and #70). I made a new Emacs plugin called python-environment.el to automatically create virtual environment and install dependencies. When this patch is pulled, you can do M-x jedi:make-env to install/update Python dependencies.

Pros

  1. No Makefile problem
  2. Virtual environment can be anywhere. I am planing to move it to ~/.emacs.d/jedi-environment so that jedi:make-env works even if you installed jedi.el in non-writable directory (e.g., system directory).
  3. In the future, we can even automatically setup everything behind the scenes when jedi.el is used at the first time.

Cons

  1. python-environment.el is additional dependency. There could be bugs (although I wrote some tests) and there is maintenance cost.
  2. Probably installation should be just up to user.

The pros 2 sounds like a good reason for this change. Assuming less about the location of jedi.el is better.

But I am still not sure if this is the right direction to go. So comments are welcome!

Pinging @asmeurer, @fgallina, @goro1080, @immerrr, @jkpl, @uchida (hopefully I am not forgetting someone who might be interested in)


Remaining TODOs:

  • Change default jedi:environment-root to ~/.emacs.d/SOMEWHERE
  • Update document
  • Update el-get recipe
Owner

tkf commented Jun 22, 2013

The purpose of this patch is to drop make dependencies, which caused some troubles in the past (see #11 and #70). I made a new Emacs plugin called python-environment.el to automatically create virtual environment and install dependencies. When this patch is pulled, you can do M-x jedi:make-env to install/update Python dependencies.

Pros

  1. No Makefile problem
  2. Virtual environment can be anywhere. I am planing to move it to ~/.emacs.d/jedi-environment so that jedi:make-env works even if you installed jedi.el in non-writable directory (e.g., system directory).
  3. In the future, we can even automatically setup everything behind the scenes when jedi.el is used at the first time.

Cons

  1. python-environment.el is additional dependency. There could be bugs (although I wrote some tests) and there is maintenance cost.
  2. Probably installation should be just up to user.

The pros 2 sounds like a good reason for this change. Assuming less about the location of jedi.el is better.

But I am still not sure if this is the right direction to go. So comments are welcome!

Pinging @asmeurer, @fgallina, @goro1080, @immerrr, @jkpl, @uchida (hopefully I am not forgetting someone who might be interested in)


Remaining TODOs:

  • Change default jedi:environment-root to ~/.emacs.d/SOMEWHERE
  • Update document
  • Update el-get recipe
@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

Ah, and try to install it if you are interested in. That would be nice.

Owner

tkf commented Jun 22, 2013

Ah, and try to install it if you are interested in. That would be nice.

@asmeurer

This comment has been minimized.

Show comment
Hide comment
@asmeurer

asmeurer Jun 22, 2013

Contributor

How easy is it with this to setup.py develop from a local clone of Jedi?

Contributor

asmeurer commented Jun 22, 2013

How easy is it with this to setup.py develop from a local clone of Jedi?

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

@asmeurer I've never used python setup.py develop but I assume it does not setup its own environment (like virtualenv does), right? If so, we can't compare them as the function is different.

Owner

tkf commented Jun 22, 2013

@asmeurer I've never used python setup.py develop but I assume it does not setup its own environment (like virtualenv does), right? If so, we can't compare them as the function is different.

@asmeurer

This comment has been minimized.

Show comment
Hide comment
@asmeurer

asmeurer Jun 22, 2013

Contributor

No, it is a way to install into an existing environment. Right now, I just did path/to/emacs-jedi/env/bin/python setup.py develop in the jedi repo. This does some path modifications so that Python will find and import the git Jedi before the one in the environment.

If this process still makes a virtualenv the same way it did before, that will still work. It would be cool if it could even be done automatically, by setting some configuration value with the path to the jedi clone, but it's not necessary.

Contributor

asmeurer commented Jun 22, 2013

No, it is a way to install into an existing environment. Right now, I just did path/to/emacs-jedi/env/bin/python setup.py develop in the jedi repo. This does some path modifications so that Python will find and import the git Jedi before the one in the environment.

If this process still makes a virtualenv the same way it did before, that will still work. It would be cool if it could even be done automatically, by setting some configuration value with the path to the jedi clone, but it's not necessary.

@asmeurer

This comment has been minimized.

Show comment
Hide comment
@asmeurer

asmeurer Jun 22, 2013

Contributor

Oh, and what setup.py develop essentially does is make it so that you can just do git pull in Jedi and it will automatically be updated without reininstalling it.

Contributor

asmeurer commented Jun 22, 2013

Oh, and what setup.py develop essentially does is make it so that you can just do git pull in Jedi and it will automatically be updated without reininstalling it.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

So it means that you need to have path/to/emacs-jedi/env/bin/python before calling setup.py develop. What python-environment.el does is to create virtualenv then install dependencies (using pip). We could be calling setup.py develop from python-environment.el instead of pip but there is no difference.

Currently virtualenv and pip are called from Makefile. python-environment.el simply replaces Makefile.

Owner

tkf commented Jun 22, 2013

So it means that you need to have path/to/emacs-jedi/env/bin/python before calling setup.py develop. What python-environment.el does is to create virtualenv then install dependencies (using pip). We could be calling setup.py develop from python-environment.el instead of pip but there is no difference.

Currently virtualenv and pip are called from Makefile. python-environment.el simply replaces Makefile.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

(@yyr could be interested in this topic, too)

Owner

tkf commented Jun 22, 2013

(@yyr could be interested in this topic, too)

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 22, 2013

Owner

To be clearer, when this is pulled, install instruction will be

M-x package-install jedi
M-x jedi:make-env

or

M-x el-get-install jedi

and they work in Linux/BSD/Mac/Windows (theoretically).

Owner

tkf commented Jun 22, 2013

To be clearer, when this is pulled, install instruction will be

M-x package-install jedi
M-x jedi:make-env

or

M-x el-get-install jedi

and they work in Linux/BSD/Mac/Windows (theoretically).

@yyr

This comment has been minimized.

Show comment
Hide comment
@yyr

yyr Jun 23, 2013

@tkf thanks for pinging me in.
let me summarize what I understood. This pull request makes installation process more portable with some additional benefits.

FWIW, I don't think additional dependency is at all a problem, we already depend few external packages, so one more is not a problem given that almost everybody use some package system.

So Personally I welcome this change.

(Not so important. I would like default virtualenv stay at HOME (~/.jedi-environment) rather than in .emacs.d)

I will try to test this and report back.

yyr commented Jun 23, 2013

@tkf thanks for pinging me in.
let me summarize what I understood. This pull request makes installation process more portable with some additional benefits.

FWIW, I don't think additional dependency is at all a problem, we already depend few external packages, so one more is not a problem given that almost everybody use some package system.

So Personally I welcome this change.

(Not so important. I would like default virtualenv stay at HOME (~/.jedi-environment) rather than in .emacs.d)

I will try to test this and report back.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 23, 2013

Owner

@yyr Yes your summary is correct.

I would like default virtualenv stay at HOME (~/.jedi-environment) rather than in .emacs.d

You can set jedi:environment-root to anywhere. As how HOME is interpreted is different from OS to OS (I mean Windows), I think putting it in .emacs.d is a better idea.

Owner

tkf commented Jun 23, 2013

@yyr Yes your summary is correct.

I would like default virtualenv stay at HOME (~/.jedi-environment) rather than in .emacs.d

You can set jedi:environment-root to anywhere. As how HOME is interpreted is different from OS to OS (I mean Windows), I think putting it in .emacs.d is a better idea.

@tkf tkf referenced this pull request in tkf/emacs-python-environment Jun 24, 2013

Closed

RFC: python-environment.el API #1

@wyuenho

This comment has been minimized.

Show comment
Hide comment
@wyuenho

wyuenho Jun 28, 2013

+1 for this. As to where jedi-environment should go, please make it configurable but default to .emacs.d/. This way it can take care of everybody.

wyuenho commented Jun 28, 2013

+1 for this. As to where jedi-environment should go, please make it configurable but default to .emacs.d/. This way it can take care of everybody.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jun 28, 2013

Owner

@wyuenho Thanks for your comment. You mean .emacs.d/SOME-DIRECTORY, right? It should be easy to put this path in .gitignore etc. so it should not be just .emacs.d.

Owner

tkf commented Jun 28, 2013

@wyuenho Thanks for your comment. You mean .emacs.d/SOME-DIRECTORY, right? It should be easy to put this path in .gitignore etc. so it should not be just .emacs.d.

@jkpl

This comment has been minimized.

Show comment
Hide comment
@jkpl

jkpl Jun 29, 2013

Contributor

Great idea. I have no preference for the jedi environment location, but I'd like it to be configurable.

Contributor

jkpl commented Jun 29, 2013

Great idea. I have no preference for the jedi environment location, but I'd like it to be configurable.

@fgallina

This comment has been minimized.

Show comment
Hide comment
@fgallina

fgallina Jul 13, 2013

Contributor

I'm absolutely +1. Another win I can foresee with this is easy automation of creation/selection of jedi envs for all my installed python versions.

Contributor

fgallina commented Jul 13, 2013

I'm absolutely +1. Another win I can foresee with this is easy automation of creation/selection of jedi envs for all my installed python versions.

@asmeurer

This comment has been minimized.

Show comment
Hide comment
@asmeurer

asmeurer Jul 13, 2013

Contributor

Does Jedi behave differently depending on what version of Python it is installed in?

Contributor

asmeurer commented Jul 13, 2013

Does Jedi behave differently depending on what version of Python it is installed in?

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Jul 14, 2013

Owner

@jkpl It's Emacs plugin. I will make it configurable for sure. :)

@fgallina That's a good point. I think I will change jedi:environment-root to take a list and rename it to jedi:environments or something.

@asmeurer You can use Jedi for different versions of Python source (you can turn on jedi-mode even in Ruby file if you want to and it will/should not crash). You might see slight difference due to change in standard library source, if you install Jedi with different versions of Python.

OK, thanks guys. I think I will pull this in after some cleanup. I am busy right now so it will be sometime later.

Owner

tkf commented Jul 14, 2013

@jkpl It's Emacs plugin. I will make it configurable for sure. :)

@fgallina That's a good point. I think I will change jedi:environment-root to take a list and rename it to jedi:environments or something.

@asmeurer You can use Jedi for different versions of Python source (you can turn on jedi-mode even in Ruby file if you want to and it will/should not crash). You might see slight difference due to change in standard library source, if you install Jedi with different versions of Python.

OK, thanks guys. I think I will pull this in after some cleanup. I am busy right now so it will be sometime later.

@tkf tkf referenced this pull request in bbatsov/prelude Jul 26, 2013

Closed

Integration with emacs-jedi #251

jedi.el
@@ -1053,6 +1061,27 @@ what jedi can do."
(jedi-mode 1))
+;;; Virtualenv setup
+(defvar jedi:make-env--command

This comment has been minimized.

@haplo

haplo Jul 29, 2013

Why the double dash "--"?

@haplo

haplo Jul 29, 2013

Why the double dash "--"?

This comment has been minimized.

@tkf

tkf Mar 7, 2014

Owner

This is a way to tell people that the variable is private.

@tkf

tkf Mar 7, 2014

Owner

This is a way to tell people that the variable is private.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Mar 7, 2014

Owner

OK, finally it is ready to merge, after this concern is solved:
tkf/emacs-python-environment#4

If you guys are still interested in this, please have a look.

Owner

tkf commented Mar 7, 2014

OK, finally it is ready to merge, after this concern is solved:
tkf/emacs-python-environment#4

If you guys are still interested in this, please have a look.

@tkf tkf referenced this pull request in dimitri/el-get Mar 8, 2014

Merged

Update for Jedi.el v0.2.0 #1603

@tkf tkf merged commit fd362ff into master Mar 10, 2014

1 check was pending

default The Travis CI build is in progress
Details
@yyr

This comment has been minimized.

Show comment
Hide comment
@yyr

yyr Mar 10, 2014

@tkf nice to see you back on firing.

yyr commented Mar 10, 2014

@tkf nice to see you back on firing.

@tkf

This comment has been minimized.

Show comment
Hide comment
@tkf

tkf Mar 10, 2014

Owner

yep!

Owner

tkf commented Mar 10, 2014

yep!

@tkf tkf referenced this pull request in melpa/melpa Mar 18, 2014

Merged

Include setup.py in jedi.el package #1588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment