Monday, April 30, 2012

Building vim with python support

Here is a walk-through of how to build vim with python2 support on a bare Arch Linux installation. This assumes that you will have no problems with conflicting packages or anything of that sort.
1) Make sure the build tools are present:
sudo pacman -S base-devel
This will install all the necessary build tools (configure, make, gcc and all those beautiful things). If you are not certain you have this, run
pacman -Ss base-devel
. This should print out the packages in the base-devel bundle. Chances are you will have
[installed]
with all of them.
2) Get the python2.7
There are a number of reasons I am using 2.7 right now, mostly amounting to scientific package support (e.g. ipython, numpy and pandas). Interestingly, Arch has python3 as the default python distribution (one more reason to love Arch, isn't it?).
sudo pacman -S python2
Now you would need to symlink the
python2
executable as
python
, both for convenience and so that the configure on vim build sees the distribution
ln -s /usr/bin/python2 /usr/bin/python
3) Get the vim source
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
4) Go to the source dict and configure everything
cd vim73/src/
./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config
5)Move the executable to the /usr/bin:
mv ./vim /usr/bin
6) Check if it all works
vim -g 
:python print 'hello vim'
That's all folks!