Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually pass source of bzip2 install for Python install?

I've been through several StackOverflow questions about Python & bzip2. These have been very helpful in getting me to the state I'm clearly at now. Here's what I've done so far and the problem I'm having:

  • I do not have root access and cannot install libbz2-dev(el)
  • /usr/bin/bzip2 is version 1.0.3
  • /usr/bin/python is version 2.4.3
  • GNU Stow is being used to manage libraries similar to how homebrew works

I need Python 2.7.3 to install with the bzip2 module in order to properly compile node.js from source. And yes, I'm sorry, but I do actually have to do all of this as a regular user from source.

I have installed bzip2 from source as follows:

$ 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

I have stow's root directory in my PATH before anything else, so this results in:

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

Which indicates that the correct bzip2 is being utilized in my PATH.

Next I move on to compiling Python from source and run the following:

$ 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

What is the correct way to tell Python during it's source configuration where the source installed bzip 1.0.6 library lives so it will detect the bzip2 devel headers and install the module properly?

like image 811
stevenhaddox Avatar asked Oct 04 '22 11:10

stevenhaddox


1 Answers

Alright, it took me a few months to get to this, but I'm finally back and managed to tackle this problem.

  • Install bzip2 from source:

    # 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...
    
  • Install Python from source:

    # 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...
    

Although node.js wasn't technically part of the question, it is what drove me to go through all of the above so I may as well include the last few commands to get node.js installed from source using a source install Python 2.7.3 & bzip2 1.0.6:

  • Install node.js from source:

    # 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
    
like image 94
stevenhaddox Avatar answered Oct 12 '22 11:10

stevenhaddox