我正在尝试针对EPD Canopy的python编译vim,但./configure似乎无法找到正确的config目录。这是我正在运行的命令
CC=clang ./configure --prefix=/usr/local \
--with-features=huge \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-perlinterp \
--enable-cscope
这是输出的相关部分
checking --enable-pythoninterp argument... yes
checking for python... /Users/noah/Library/Enthought/Canopy_64bit/User/bin/python
checking Python version... 2.7
checking Python is 1.4 or better... yep
checking Python's install prefix... /Users/noah/Library/Enthought/Canopy_64bit/User
checking Python's execution prefix... /Users/noah/Library/Enthought/Canopy_64bit/User
checking Python's configuration directory...
can't find it!
现在,Canopy.app包中有一个config
目录,所以我也尝试添加标记--with-python-config-dir=/Applications/Canopy.app/Contents/lib/python2.7/config
。这给出了错误
checking if compile and link flags for Python are sane... no: PYTHON DISABLED
我没有想法。谢谢你的帮助。
答案 0 :(得分:2)
请务必先运行make distclean
以清除失败构建中缓存的所有内容。
以下适用于我(在Debian Wheezy 64位上)(您需要将$VIM_SRC
和$CANOPY_SRC
更改为您的vim和canopy的任何位置迪尔斯)。
VIM_SRC=~/src/vim73
CANOPY_SRC=~/src/canopy
cd $VIM_SRC
make distclean
# Compile against canopy python and install in canopy dir, so that
# this vim is used when canopy is activated.
# YOU HAVE TO HAVE CANOPY ACTIVATED, i.e. `which python` points to canopy
# you also need python-config
# (this assumes you can install into your canopy install
# dir, but it isn't strictly necessary)
APPDATA=$CANOPY_SRC/appdata/canopy-1.0.3.1262.rh5-x86_64
PYTHON_CONFIG=$APPDATA/lib/python2.7/config
# I'm installing here so that this is the vim used when I start the virtualenv,
# but you can put it where you like.
INSTALL_DIR=$CANOPY_SRC/Enthought/Canopy_64bit/User/
# force vim to use this python binary
export vi_cv_path_python=$APPDATA/bin/python
./configure --prefix=$INSTALL_DIR \
--with-features=big \
--enable-pythoninterp=yes \
--with-python-config-dir=$PYTHON_CONFIG \
# I didn't actually need these flags. python-config is a helper script
# that comes with the Debian package python-dev. I'm leaving them here
# in case someone finds them useful.
# CFLAGS="`python-config --includes`" \
# LIBS="`python-config --libs`" \
# LDFLAGS="`python-config --ldflags`"
make
make install
诀窍是设置vi_cv_path_python
以强制vim使用可以导入网站的python。
使用
进行测试vim -c ':py import os; print os.__file__'
这无法导入共享对象,例如vim -c ':py import zmq'
。 LD_LIBRARY_PATH
可以fix这个。
设置LD_LIBRARY_PATH
后调用vim:
alias vim="LD_LIBRARY_PATH='$APPDATA/lib' vim"
如果您使用CFLAGS="
python-config --cflags "
或者根本不提供此版本,则较旧版本的Vim将失败。这是因为这在gcc args中包含-O2
,这将导致vim segfault。这就是我放--includes
的原因。 我的解决方案适用于最新的development snapshot 。
答案 1 :(得分:0)
这看起来像是因为Canopy不像EPD和系统python那样构建框架,并且MacVim在编译期间使用-framework选项。您可以通过设置一些符号链接,并在编译过程中修改一些路径来完成这项工作。
首先,在/ System / Library中将Python.framework符号链接创建到/Applications/Canopy.app中的Python文件,如下所示(根据您的Canopy版本根据需要进行修改): ln -s /Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents
使用您喜欢的选项运行configure脚本(我省略了python-config-dir): ./configure --with-features = huge --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-cscope --disable-netbeans
修改src / auto / config.mk,如下所示:
PYTHON_CFLAGS = -I / Applications / Canopy.app / appdata / canopy-1.0.3.1262.macosx-x86_64 / Canopy.app / Contents / include / python2.7 -DPYTHON_HOME ='“/ Applications / Canopy.app / appdata /canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents“'
PYTHON_GETPATH_CFLAGS = ..(无论是由config生成的......)-DPREFIX ='“/ Applications / Canopy.app / appdata / canopy-1.0.3.1262.macosx-x86_64 / Canopy.app / Contents”' - DEXEC_PREFIX ='“/ Applications / Canopy.app / appdata / canopy-1.0.3.1262.macosx-x86_64 / Canopy.app / Contents”'
编辑src / if_python.c(第59行)以读取#include Python.h而不是Python / Python.h
这应该正确编译。但是,运行vim时有一个rpath问题,我没有足够的经验(如果你了解它,请分享)。所以我只需在/ usr / lib中创建一个符号链接到Python库就可以解决这个问题:
ln -s /Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/Python / usr / lib / Python
你也可以导出一个DYLD_LIBRARY_PATH,但是不应该做这样的事情 - 应该构建一个可执行文件,知道在哪里找到它的库。但正如我所说,我是一个业余爱好者。