Compiling vim with Python3 (installed via Homebrew) support?

neezer picture neezer · May 28, 2011 · Viewed 9.5k times · Source

I have python3 installed via homebrew: brew install python3 --framework

I have the vim source (7.3) downloaded in /usr/src

I run:

./configure --prefix=/usr/local --enable-rubyinterp --enable-python3interp --disable-gpm --enable-gui=no --enable-multibyte

And in my src/auto/config.log I see:

configure:5442: checking --enable-python3interp argument   
configure:5451: result: yes  
configure:5456: checking for python3  
configure:5489: result: no

I googled around some, and found this, so I tried making the symlink for python3.2 and then running configure like this:

./configure --prefix=/usr/local --enable-rubyinterp --enable-python3interp --disable-gpm --enable-gui=no --enable-multibyte --with-python3-config-dir=/usr/local/Cellar/python3/3.2/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config-3.2m

And my log shows the same error. What do I need to do to get vim compiled with Python3 support?

And no: I do not want to use MacVim.


➜ ls -al /System/Library/Frameworks/Python.framework/Versions 
total 16
drwxr-xr-x   7 root  wheel  238 May 28 15:33 .
drwxr-xr-x   7 root  wheel  238 Sep 21  2010 ..
drwxr-xr-x   8 root  wheel  272 Sep 17  2010 2.3
drwxr-xr-x  12 root  wheel  408 Dec  1 12:49 2.5
drwxr-xr-x  12 root  wheel  408 Dec  1 12:49 2.6
lrwxr-xr-x   1 root  wheel   70 May 28 15:33 Current -> /usr/local/Cellar/python3/3.2/Frameworks/Python.framework/Versions/3.2
lrwxr-xr-x   1 root  wheel    3 Sep 17  2010 old-Current -> 2.6

➜ which python3.2
/usr/local/bin/python3.2

UPDATE: I've gotten it working a la this post with Python 2.7.1 via Homebrew, but still no joy with Python 3...

Answer

CodedReality picture CodedReality · Jun 16, 2011

There is a problem with the configure script. Since python 3.2 the config and include directories get the abiflag included (see PEP 3149).

The next problem is that the configure script parses the python config and the flags for the linker are not correct for a framework build, so the test program from the configure script fails to build.

I already send a patch to vim and it got included (the mercurial repo has it).

`./configure --enable-python3interp vi_cv_path_python3=/usr/local/bin/python3.2`

should work.

Vim Patch: https://github.com/codedreality/vim/tree/fix-python3x-support

MacVim Patch: https://github.com/codedreality/macvim/tree/fix-python3x-support