如何手动传递 bzip2 安装源以进行 Python 安装?

问题描述 投票:0回答:1

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

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

我需要 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

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

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

这表明我的路径中正在使用正确的 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 devel 标头并正确安装模块?

python node.js python-2.7 bzip2
1个回答
4
投票

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

  • 从源安装 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 CFLAGS="-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 不是问题的一部分,但它是促使我完成上述所有内容的原因,因此我也可以包含最后几个命令,以使用源安装 Python 2.7 从源安装 node.js .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
    
© www.soinside.com 2019 - 2024. All rights reserved.