【问题标题】:How to manually pass source of bzip2 install for Python install?如何为 Python 安装手动传递 bzip2 安装源?
【发布时间】:2013-04-09 18:53:09
【问题描述】:

我已经解决了几个关于 Python 和 bzip2 的 StackOverflow 问题。这些对于让我达到我现在清楚的状态非常有帮助。这是我到目前为止所做的以及我遇到的问题:

  • 我确实没有具有 root 访问权限并且无法安装 libbz2-dev(el)
  • /usr/bin/bzip2 是 1.0.3 版本
  • /usr/bin/python 是 2.4.3 版
  • GNU Stow 被用于管理类似于 homebrew 工作方式的库

我需要 Python 2.7.3 来安装 bzip2 模块,以便从源代码正确编译 node.js。是的,我很抱歉,但我确实必须以普通用户的身份从源头上完成所有这些工作。

我已经从源代码安装了 bzip2,如下所示:

$ make -f Makefile-libbz2_so
$ make
$ make install PREFIX=${STOW}/bzip2-1.0.6
$ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/
$ cd ${STOW}/bzip2-1.0.6/lib
$ ln -s libbz2.so.1.0.6 libbz2.so.1.0
$ cd ${STOW}
$ stow bzip2-1.0.6

我将 PATH 的根目录放在我的 PATH 中,所以这会导致:

$ bzip2 -V
# [...] Version 1.0.6

这表明在我的 PATH 中使用了正确的 bzip2。

接下来我继续从源代码编译 Python 并运行以下命令:

$ cd Python-2.7.3
$ ./configure --prefix=${STOW}/Python-2.7.3
$ make
# Complains about several missing modules, of which "bz2" is the one I care about
$ make install prefix=${STOW}/Python-2.7.3 # unimportant as bz2 module failed to install

在源代码配置期间告诉 Python 源安装 bzip 1.0.6 库的位置的正确方法是什么,以便它能够检测 bzip2 开发头文件并正确安装模块?

【问题讨论】:

  • 看起来我可能想要类似于 ./configure --libdir=${STOW}/../lib --prefix=${STOW}/Python-2.7.3 的东西来改变 bz2从找不到到建不起来……
  • 我已经用--enable-shared 标志尝试了以上所有方法,但一旦我实际安装了 Python,它就无法正常运行。删除该标志至少可以让 Python 在此 VM 上正确地从源代码安装和运行。不幸的是,关于 bz2 模块安装问题,这并没有改变任何东西(无论哪种方式)。

标签: python node.js python-2.7 bzip2


【解决方案1】:

好吧,我花了几个月的时间才解决这个问题,但我终于回来并设法解决了这个问题。

  • 从源安装 bzip2:

    # Upload bzip2-1.0.6.tar.gz to ${SRC}
    $ cd ${SRC}
    $ tar -xzvf bzip2-1.0.6.tar.gz
    $ cd bzip2-1.0.6
    $ export CFLAGS="-fPIC"
    $ make -f Makefile-libbz2_so
    $ make
    $ make install PREFIX=${STOW}/bzip2-1.0.6
    $ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/
    $ cd ${STOW}/bzip2-1.0.6/lib
    $ ln -s libbz2.so.1.0.6 libbz2.so.1.0
    $ cd ${STOW}
    $ stow bzip2-1.0.6
    $ source ${HOME}/.bash_profile
    $ bzip2 --version
    #=> bzip2, a block-soring file compressor. Version 1.0.6...
    
  • 从源代码安装 Python:

    # Upload Python-2.7.3.tar.gz to ${SRC}
    $ cd ${SRC}
    $ tar -xzvf Python-2.7.3.tar.gz
    $ cd Python-2.7.3
    $ export CLFAGS="-fPIC"
    $ export C_INCLUDE_PATH=${STOW}/../include
    $ export CPLUS_INCLUDE_PATH=${C_INCLUDE_PATH}
    $ export LIBRARY_PATH=${STOW}/../lib
    $ export LD_RUN_PATH=${LIBRARY_PATH}
    $ ./configure --enable-shared --prefix=${STOW}/Python-2.7.3 --libdir=${STOW}/../lib
    $ make
    $ make install prefix=${STOW}/Python-2.7.3
    $ cd ${STOW}
    $ stow Python-2.7.3
    $ source ${HOME}/.bash_profile
    $ python -V
    #=> Python 2.7.3
    $ python -c "import bz2; print bz2.__doc__"
    #=> The python bz2 module provides...
    

虽然从技术上讲 node.js 不是问题的一部分,但它是驱使我完成上述所有内容的原因,所以我不妨包括最后几个命令,以使用源安装从源安装 node.js Python 2.7.3 & bzip2 1.0.6:

  • 从源代码安装 node.js:

    # Upload node-v0.10.0.tar.gz to ${SRC}
    $ cd ${SRC}
    $ tar -xzvf node-v0.10.0.tar.gz
    $ cd node-v0.10.0
    $ ./configure --prefix=${STOW}/node-v0.10.0
    $ make
    $ make install prefix=${STOW}/node-v0.10.0
    $ cd ${STOW}
    $ stow node-v0.10.0
    $ source ${HOME}/.bash_profile
    $ node -v
    #=> v0.10.0
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 2015-05-01
    • 2017-03-28
    相关资源
    最近更新 更多