<!-- Hi -->
Chrismurf.com
Setting up Redland and Python on Dreamhost
As the daylily site is built entirely on semantic web technologies (RDF/SPARQL), I wanted Redland (aka librdf) so that I could perform SPARQL queries without having each request take five minutes. The PHP solutions all just seemed too slow. It took me quite a while to figure out how to install redland, even after realizing I would need to install my own version of Python in my home directory.
Here's a description of how I setup Python, Redland, and a few other useful packages on my dreamhost shared hosting account. I'm glossing over some of the details (like how to unzip a tarball) because really, you should probably be comfortable with the basics if you're going to go this route. I've replaced version numbers with "-xxx" in some places, you should substitute whatever version you are using. I used Python 2.4.3 and Redland 1.0.4.
Anyplace you see 'USERNAME', you should replace it with your dreamhost username.
First, get the redland, redland-bindings, and python-2.4 source. Save them all in /home/USERNAME/usr/src/, and unzip each tarball.
Redland
To build + install redland, first change into the redland-1.0.x directory and then:
- Configure redland with: ./configure --prefix=/home/USERNAME/usr/
- Make redland with: make
- Install redland with: make install
Python
To build + install Python, first change into the Python-xxx directory and then:
- export LD_RUN_PATH='/home/USERNAME/usr/lib/'
- export LDFLAGS="-L/home/USERNAME/usr/lib/ -Wl,-rpath /home/USERNAME/usr/lib/"
- Configure python with: ./configure --prefix=/home/USERNAME/usr/
- Make python with: make
- Install python with: make install
Redland-bindings
To build + install Python, first move the unzipped redland-bindings directory into the redland-1.0.x folder. If you don't do this, redland bindings will not find the Redland source as you compile it.
Next, change into the redland-1.0.x/redland-bindings-xxx/ directory and:
- Configure with: ./configure --prefix=/home/USERNAME/usr --with-python=/home/USERNAME/usr/bin/python2.4
- Make with: make
- install with: make install
Misc. Python packages with setup.py
I also needed a few other python packages - specifically flup, so that I could use fastcgi, and Cheetah for templating. To install those packages, just unzip them into ~/usr/src and run: 'python setup.py install --prefix=/home/USERNAME/usr' in each folder.
Redland's comments after install
After doing "make install", redland will output this warning message:
* If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
I'm relatively certain that I address that when I compile python with the LD_RUN_PATH variable, and the linker flags.
Afterthoughts
After you've done all this, you should have python ready to go. By default, if you type "python" at the prompt you will receive the dreamhost python. To fix this, you can update your PATH variable to include /home/USERNAME/usr/bin/ before the current PATH. You can also just point the 'shebang' line at the top of your python file at /home/USERNAME/usr/bin/python2.4.
Please send corrections / comments to chrismurf at gmail.
