在Homebrew安装的Python3下编译vim支持?
我通过Homebrew安装了Python3,命令是:brew install python3 --framework
我把vim的源代码(版本7.3)下载到了/usr/src
这个目录下。
我执行了:
./configure --prefix=/usr/local --enable-rubyinterp --enable-python3interp --disable-gpm --enable-gui=no --enable-multibyte
然后在我的src/auto/config.log
文件里,我看到了:
configure:5442: checking --enable-python3interp argument
configure:5451: result: yes
configure:5456: checking for python3
configure:5489: result: no
我在网上查了一下,发现了这个链接,于是我尝试为python3.2创建一个符号链接,然后像这样运行配置:
./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
但是我的日志里还是显示同样的错误。我需要做些什么才能让vim支持Python3编译呢?
另外,我不想使用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
更新:我按照这个帖子的方法,用Homebrew安装了Python 2.7.1,成功了,但用Python 3还是不行...
3 个回答
我把macvim的标题栏颜色改成了黑色。我的macvim配色方案是ayu dark。
要修改macvim,找到MMWindow.m
文件的第93行,然后在后面加上以下代码:
[self setTitleVisibility:NSWindowTitleHidden];
[self setTitlebarAppearsTransparent:YES];
self.backgroundColor = NSColor.blackColor;
用下面的命令来编译源代码:
./configure --with-features=huge --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-rubyinterp --enable-tclinterp --enable-terminal --enable-python3interp --with-properly-linked-python2-python3 --enable-python3interp=yes --enable-cscope
当你测试是否成功时,确保使用的是通过构建生成的Vim二进制文件,而不是mvim脚本。因为mvim(即使你调用的是源代码目录中的版本)会优先在/Applications/文件夹中寻找MacVim.app。
也许这会让你感到高兴:
./configure \
--enable-python3interp=dynamic \
--with-python3-config-dir=/usr/local/Cellar/python3/3.2/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config/
这个配置脚本有点问题。从Python 3.2开始,配置和包含的目录会把abiflag也包含进去(具体可以参考PEP 3149)。
下一个问题是,这个配置脚本在解析Python的配置时,链接器的标志对于框架构建来说不正确,所以配置脚本中的测试程序无法成功构建。
我已经给Vim发了一个补丁,并且这个补丁已经被采纳了(在Mercurial的仓库里可以找到)。
`./configure --enable-python3interp vi_cv_path_python3=/usr/local/bin/python3.2`
应该可以正常工作。
Vim补丁: https://github.com/codedreality/vim/tree/fix-python3x-support
MacVim补丁: https://github.com/codedreality/macvim/tree/fix-python3x-support