【问题标题】:Compiling vim against EPD Canopy: no lib/config directory针对 EPD Canopy 编译 vim:没有 lib/config 目录
【发布时间】:2013-06-16 13:02:28
【问题描述】:

我正在尝试针对 EPD Canopy 的 python 编译 vim,但 ./configure 似乎找不到正确的配置目录。这是我正在运行的命令

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

zh我没有想法。感谢您的帮助。

【问题讨论】:

    标签: python vim enthought


    【解决方案1】:

    确保首先运行 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 参数中包含 -O2,这将导致 vim 到 segfault。这就是我输入--includes 的原因。 我的解决方案适用于最新的development snapshot

    【讨论】:

    • 我再次尝试使用 EPD 和这个 python-config 提示,但没有骰子:(
    • 我可以编译它,但是在 Vim 中调用 :py 在出现关于找不到模块站点的错误后会崩溃:(
    • 我在使用 Debian Wheezy 64 位。
    • 现在您也不必使用python-config。 YMMV。我对 OSX 或 MacVim 的了解为零。
    【解决方案2】:

    这看起来是因为 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

    • 使用您喜欢的选项运行配置脚本(我省略了 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= ..(无论由配置生成)... -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,但不应该做这样的事情——构建可执行文件时应该知道在哪里可以找到它的库。但正如我所说,我是一个业余爱好者。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-07
      • 2023-04-03
      • 2013-10-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 2016-06-08
      相关资源
      最近更新 更多