Vim failing to compile with python on OS X


Question

I've been trying to compile vim 7.3 with python 2.7 support on mac OS X 10.6. Vim itself compiles fine, but the embedded python not so much.

The steps I've taken:

hg clone https:/vim.googlecode.com/hg/ vim
cd vim/src
./configure --without-x --disable-gui --disable-darwin \
            --enable-pythoninterp --with-features=huge
make
make install

That gives me a working vim but without python.

The auto/config.log indicates there's a file error:

configure:5387: checking if compile and link flags for Python are sane
configure:5404: gcc -o conftest -g -O2 
     -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 
     -DPYTHON_HOME=\"/Library/Frameworks/Python.framework/Versions/2.7\"   
     -L/usr/local/lib conftest.c  
     -L/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config 
     -lpython2.7 -ldl -framework CoreFoundation 
     -u _PyMac_Error Python.framework/Versions/2.7/Python >&5
i686-apple-darwin10-gcc-4.2.1: Python.framework/Versions/2.7/Python: No such file or directory

<command-line>: warning: missing terminating " character
configure:5404: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define UNIX 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define FEAT_HUGE 1
| #define USE_XSMP_INTERACT 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
|  
|   ;
|   return 0;
| }
configure:5408: result: no: PYTHON DISABLED

I get this error whether I run configure with or without the --with-python-conf-dir option. It looks like the -u _PyMac_Error Python.framework/Versions/2.7/Python is the source of the problem, but I'm not sure where to go from here.

Any suggestions?

1
7
6/27/2011 8:52:49 AM

Accepted Answer

Romainl gave the accepted answer: MacVim comes with a command-line version of vim as well as the gui version - something I was not aware of - and I had already successfully compiled MacVim with Python 2.7 (without any of the problems I ran into with the standard vim sources).

Using macports or homebrew was not an option I was looking at.

N.B. if anyone can asign this answer to Romainl, please go ahead and do so. I'm only answering myself to close this one off.

0
8/13/2011 8:31:36 AM

Turns out the bug is actually in the Python Makefile, believe it or not.

Open the file

/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config

or whatever the appropriate path is for you, and search for PyMac_Error. It should be on the line defining LINKFORSHARED, and on this line you need to change PYTHONFRAMEWORKDIR to PYTHONFRAMEWORKINSTALLDIR. Then go back to your vim source and ./configure, everything should go smooth.

Also make sure you symlink OS X's Python Frameworks to the ones in the Homebrew Cellar:

/Library/Frameworks/Python.framework/Versions/2.7
/Library/Frameworks/Python.framework/Versions/Current
/System/Library/Frameworks/Python.framework/Versions/2.7
/System/Library/Frameworks/Python.framework/Versions/Current

should all point to

/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7

Not really sure why I had it in so many places, or if that's bad, but there it is.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon