如何手动将bzip2安装源传递给Python安装?

2024-05-16 19:51:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经讨论过关于Python&bzip2的几个StackOverflow问题。这些对我现在的状态很有帮助。以下是我到目前为止所做的以及我遇到的问题:

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

我需要python2.7.3与bzip2模块一起安装,以便正确编译节点.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的根目录,所以这会导致:

^{pr2}$

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


Tags: 模块install路径版本prefixmakebin源代码
1条回答
网友
1楼 · 发布于 2024-05-16 19:51:04

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

  • 从源安装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...
    

尽管节点.js技术上并不是问题的一部分,而是什么驱使我经历了以上所有的,所以我也可以包括最后几条命令节点.js使用源代码安装Python 2.7.3和bzip2 1.0.6从源代码安装:

  • 安装节点.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
    

相关问题 更多 >