Saturday, June 9, 2012

Install bzr bazaar with out root privilege


Here are the steps that I followed to install bzr locally (in my user directory without root access) without using gcc.
Although you do not need to install it on your server, I still wanted to. The reason being that I cannot find any decent cgi that will let me browse the content of my bzr repository from the web. The easiest way is to install bzr and have it used by a script query and stat your repository from your web page.
So again, you do not need to install bzr on the server (for me, that was the whole point of using Bazaar in the first place). Still here’s how I got it to install:

1. Log on to Your Server

1
ssh myserver

2. Get the Source

The source code is available from theBazaar Download page at http://bazaar-vcs.org/Download. Under “Source of the stable release for any platform”, you’ll find a link to the source code:
1
2
3
4
5
$server:~>mkdir bzr-temp
$server:~>cd bzr-temp
$server:bzr-temp>wget http://launchpad.net/bzr/2.0/2.0.5/+download/bzr-2.0.5.tar.gz
$server:bzr-temp>tar -zxvf bzr-2.0.5.tar.gz
$server:bzr-temp>cd bzr-2.0.5

3. Compile the Source Locally Without gcc

My server does not give me access to gcc (they don’t really want me to start programming on the web server, I guess installing custom software, even locally, is borderline…).
Usually, to install locally (in $HOME), you’d simply run the following command:
1
$server:bzr-2.0.5>python setup.py install --home $HOME
But in this case, I ended up with
1
2
3
4
5
6
7
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.4 -c bzrlib/_annotator_pyx.c -o build/temp.linux-x86_64-2.4/bzrlib/_annotator_pyx.o
unable to execute gcc: Permission denied

Cannot build extension "bzrlib._annotator_pyx".
Use "build_ext --allow-python-fallback" to use slower python implementations instead.

error: command 'gcc' failed with exit status 1
Since gcc cannot be used, we’ll have to run the “slower” python implementation. This was achieved by adding the suggested arguments:
1
$server:bzr-2.0.5>python setup.py install --home $HOME build_ext --allow-python-fallback
This compiled and installed successfully.

4. Set the PYTHONPATH Environment Variable

Running “bzr” from the command line, I’d get the following error:
1
2
3
4
5
6
7
8
$server:~>bzr
bzr: ERROR: Couldn't import bzrlib and dependencies.
Please check the directory containing bzrlib is on your PYTHONPATH.

Traceback (most recent call last):
File "/home2/enseed/bin/bzr", line 107, in ?
import bzrlib
ImportError: No module named bzrlib
All you need to do is add the path to your local python libraries to the PYTHONPATH environment variable. This can be done in your .bashrc by adding an export directive
1
export PYTHONPATH=~/lib64/python/
(in your case, it might be at some other place than lib64, check it up)
Or, simply define the variable when you execute bzr:
1
$server:~>PYTHONPATH=~/lib64/python/ bzr


No comments:

Post a Comment