How to make vim embed my own custom version of python ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to make vim embed my own custom version of python ?

Jacky Liu
I'm making a custom version of python with some self written C++ extensions, I don't want to mess with the default installation on my Ubuntu so I installed it to .local/ under my own home directory.

Now I also like to make a custom version of vim to embed my own version of python, is there any way to do this? As far as I know there are very limited options to configure's arguments, like  --enable-python3interp=yes  but I'm not aware of any method to specify which python to use. Thanks.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to make vim embed my own custom version of python ?

Tony Mechelynck
Configure has a lot, but really a lot, of possible arguments. To see
them all, use

    src/auto/configure --help |less

For your usecase, I think the following might perhaps be relevant (but
you might want to read it all):

  --enable-pythoninterp=OPTS   Include Python interpreter. default=no
OPTS=no/yes/dynamic
  --enable-python3interp=OPTS   Include Python3 interpreter.
default=no OPTS=no/yes/dynamic

  --with-plthome=PLTHOME   Use PLTHOME.
  --with-python-config-dir=PATH  Python's config directory
  --with-python3-config-dir=PATH  Python's config directory

Also, --disable-blablabla is equivalent to --enable-blablabla=no and
--without-blablabla is equivalent to --with-blablabla=no for any value
of blablabla.

In any case, I recommend not to edit the makefile, and not to invoke
configure directly yourself with arguments on the command-line, but
instead to set the configure arguments by means of environments
variables set by sourcing a script, so you can be sure to use the
right arguments every time.

For details, see the last two links above the bottom line of
http://users.skynet.be/antoine.mechelynck/vim/

Best regards,
Tony.

On Sun, Apr 2, 2017 at 8:49 PM, Jacky Liu <[hidden email]> wrote:

> I'm making a custom version of python with some self written C++ extensions, I don't want to mess with the default installation on my Ubuntu so I installed it to .local/ under my own home directory.
>
> Now I also like to make a custom version of vim to embed my own version of python, is there any way to do this? As far as I know there are very limited options to configure's arguments, like  --enable-python3interp=yes  but I'm not aware of any method to specify which python to use. Thanks.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to make vim embed my own custom version of python ?

Jacky Liu
On Monday, April 3, 2017 at 11:11:27 AM UTC+8, Tony Mechelynck wrote:

> Configure has a lot, but really a lot, of possible arguments. To see
> them all, use
>
>     src/auto/configure --help |less
>
> For your usecase, I think the following might perhaps be relevant (but
> you might want to read it all):
>
>   --enable-pythoninterp=OPTS   Include Python interpreter. default=no
> OPTS=no/yes/dynamic
>   --enable-python3interp=OPTS   Include Python3 interpreter.
> default=no OPTS=no/yes/dynamic
>
>   --with-plthome=PLTHOME   Use PLTHOME.
>   --with-python-config-dir=PATH  Python's config directory
>   --with-python3-config-dir=PATH  Python's config directory
>
> Also, --disable-blablabla is equivalent to --enable-blablabla=no and
> --without-blablabla is equivalent to --with-blablabla=no for any value
> of blablabla.
>
> In any case, I recommend not to edit the makefile, and not to invoke
> configure directly yourself with arguments on the command-line, but
> instead to set the configure arguments by means of environments
> variables set by sourcing a script, so you can be sure to use the
> right arguments every time.
>
> For details, see the last two links above the bottom line of
> http://users.skynet.be/antoine.mechelynck/vim/
>
> Best regards,
> Tony.
>

You were right about using environment variables instead of arguments. After carefully checking /src/auto/configure I added this line to my script:

    export vi_cv_path_python3=/home/mydir/.local/bin/python3.6

and it worked, vim found the specified version of Python.

Thank you !



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to make vim embed my own custom version of python ?

Tony Mechelynck
On Mon, Apr 3, 2017 at 2:13 PM, Jacky Liu <[hidden email]> wrote:

> On Monday, April 3, 2017 at 11:11:27 AM UTC+8, Tony Mechelynck wrote:
>> Configure has a lot, but really a lot, of possible arguments. To see
>> them all, use
>>
>>     src/auto/configure --help |less
>>
>> For your usecase, I think the following might perhaps be relevant (but
>> you might want to read it all):
>>
>>   --enable-pythoninterp=OPTS   Include Python interpreter. default=no
>> OPTS=no/yes/dynamic
>>   --enable-python3interp=OPTS   Include Python3 interpreter.
>> default=no OPTS=no/yes/dynamic
>>
>>   --with-plthome=PLTHOME   Use PLTHOME.
>>   --with-python-config-dir=PATH  Python's config directory
>>   --with-python3-config-dir=PATH  Python's config directory
>>
>> Also, --disable-blablabla is equivalent to --enable-blablabla=no and
>> --without-blablabla is equivalent to --with-blablabla=no for any value
>> of blablabla.
>>
>> In any case, I recommend not to edit the makefile, and not to invoke
>> configure directly yourself with arguments on the command-line, but
>> instead to set the configure arguments by means of environments
>> variables set by sourcing a script, so you can be sure to use the
>> right arguments every time.
>>
>> For details, see the last two links above the bottom line of
>> http://users.skynet.be/antoine.mechelynck/vim/
>>
>> Best regards,
>> Tony.
>>
>
>
> You were right about using environment variables instead of arguments. After carefully checking /src/auto/configure I added this line to my script:
>
>     export vi_cv_path_python3=/home/mydir/.local/bin/python3.6
>
> and it worked, vim found the specified version of Python.
>
> Thank you !
>
>
I meant setting configure arguments as environment variables to make,
but since it works for you, so much the better.

This is the script I source (running it isn't enough) when opening the
terminal where I'll be compiling Vim (and I may then compile it
repeatedly as new patches arrive, without sourcing the script again:

#!/bin/bash
export CONF_OPT_GUI='--enable-gui=gtk3 --enable-gnome-check'
export CONF_OPT_PERL='--enable-perlinterp'
export CONF_OPT_PYTHON='--enable-pythoninterp'
export CONF_OPT_PYTHON3='--disable-python3interp'
export CONF_OPT_TCL='--enable-tclinterp'
# /usr/bin/tclsh (softlink) is correctly set
export CONF_OPT_RUBY='--enable-rubyinterp'
export CONF_OPT_LUA='--enable-luainterp'
export CONF_OPT_MZSCHEME='--disable-mzschemeinterp'
#export CONF_OPT_PLTHOME='--with-plthome=/usr/local/plt'
export CONF_OPT_CSCOPE='--enable-cscope'
export CONF_OPT_MULTIBYTE='--enable-multibyte'
export CONF_OPT_FEAT='--with-features=huge'
export CONF_OPT_COMPBY='"--with-compiledby=[hidden email]"'

The shebang line is probably unneeded, since this script must be
"sourced" by the instance of bash which will be running make, not
"run" as a program (which would get its own environment, forgotten on
return).

And I repeat, I never invoke configure on the command-line but only
through make: "make config" or "make reconfig", and sometimes just
plain "make" decides that it needs to run configure anyway. In all
these cases, especially the latter one, the correct configure
arguments are set.

If there is a command-line configure argument for the Python path
(--with-python3-config-dir maybe? On my system, python3-config is a
Python script which, just like the Python3 interpreter, lives in
/usr/bin) you could have added it space-separated inside the value for
CONF_OPT_PYTHON3, something like

export CONF_OPT_PYTHON3='--enable-python3interp
--with-python3-config-dir=/home/jackyliu/.local/dir'

If you haven't changed python-config, and haven't copied it or linked
it in your patched Python interpreter's directory, then I suppose your
hack of setting $vi_cv_path_python3 is the least bad solution.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to make vim embed my own custom version of python ?

Jacky Liu

> If there is a command-line configure argument for the Python path
> (--with-python3-config-dir maybe? On my system, python3-config is a
> Python script which, just like the Python3 interpreter, lives in
> /usr/bin) you could have added it space-separated inside the value for
> CONF_OPT_PYTHON3, something like
>
> export CONF_OPT_PYTHON3='--enable-python3interp
> --with-python3-config-dir=/home/jackyliu/.local/dir'
>
> If you haven't changed python-config, and haven't copied it or linked
> it in your patched Python interpreter's directory, then I suppose your
> hack of setting $vi_cv_path_python3 is the least bad solution.
>
> Best regards,
> Tony.

Nope, just setting --with-python3-config-dir is not sufficient, configure yielded result like this:

    checking --enable-python3interp argument... yes
    checking for python3... /usr/bin/python3
    checking Python version... 3.5
    checking Python is 3.0 or better... yep
    checking Python's abiflags... m
    checking Python's install prefix... /usr
    checking Python's execution prefix... /usr
    checking Python's configuration directory... (cached) /home/jacky/Build/PythonX/python3_pyx/Python-3.6.1
    checking Python3's dll name... libpython3.6m.so.1.0

Note configure still looks into /usr to try to find python, and it found 3.5。I suppose setting the variable $vi_cv_path_python3 can't be avoided, maybe my need is too rare?

Also I learned these:

*. Python has to be configured with the --enable-shared option on.
*. Vim has to be configured with this variable set properly:
    export LD_LIBRARY_PATH=/home/jacky/.local/lib

and the same with the later invoking of Vim, I added it into my .bashrc。

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...