Notes on working with Amara on Mac

For most users (Snow Leopard)

Snow Leopard comes with Python 2.6, which is already smart enough to look for modules in /Users/uche/.local/lib/python2.6/site-packages/, so no need for updating the PYTHONPATH

[install]
#Install to user directory rather than system site-packages
prefix = ~/.local

curl -O http://python-distribute.org/distribute_setup.py
mkdir -p $HOME/.local/lib/python2.6/site-packages/
python distribute_setup.py
easy_install python-dateutil

Install Amara from a nightly snapshot:

mkdir $HOME/dl; cd $HOME/dl
wget http://files.akara.info/00-amara-latest.tar.bz2
mkdir $HOME/src; cd $HOME/src
tar jxvf $HOME/dl/00-amara-latest.tar.bz2
cd amara
python setup.py install

You may need to update PATH and PYTHONPATH, e.g. by adding (on Linux) the following to the ~/.profile (and running it on the command line for the first time)

export PATH=$PATH:~/.local/bin
export PYTHONPATH=$PYTHONPATH:~/.local/lib/python 

For most users (Leopard)

[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin

mkdir $HOME/Library/Python/2.5/site-packages

easy_install python-dateutil html5lib

Install Amara from a nightly snapshot:

mkdir $HOME/dl; cd $HOME/dl
wget http://files.akara.info/00-amara-latest.tar.bz2
mkdir $HOME/src; cd $HOME/src
tar jxvf $HOME/dl/00-amara-latest.tar.bz2
cd amara
python setup.py install

You may need to update PATH and PYTHONPATH, e.g. by adding (on Linux) the following to the ~/.profile (and running it on the command line for the first time)

export PATH=$PATH:~/.local/bin
export PYTHONPATH=$PYTHONPATH:~/.local/lib/python 

Using the latest released version

easy_install amara

(For developers) Using and following the latest dev snapshot

mkdir $HOME/dev
cd $HOME/dev
hg clone http://bitbucket.org/uche/amara/ amara-HG # You can also clone from http://hg.xml3k.org/amara
cd amara-HG
python setup.py install
cd #Avoid trying to import Amara from this directory

And you're set.

<!> Do not try to import or run amara from the source directory ($HOME/dev/amara-HG) or you will get strange errors

You may need to update PATH and PYTHONPATH, e.g. by adding (on Linux) the following to the ~/.profile (and running it on the command line for the first time)

export PATH=$PATH:~/.local/bin
export PYTHONPATH=$PYTHONPATH:~/.local/lib/python 

If you need Amara 2.x to coexist with Amara 1.x

One way to use Amara 2.x without interfering with your existing libraries (including Amara 1.x) is use virtualenv. You should be able to easy_install virtualenv. Create a directory for the sandbox, and set that directory as $AKARAHOME.

export AKARAHOME=$HOME/Library/Akara
mkdir $AKARAHOME

Then to set up the sandbox:

#The following is only needed once
virtualenv --no-site-packages $AKARAHOME #
source $AKARAHOME/bin/activate

You now have a subshell with a clean Python slate, and you can install Amara2 here:

mkdir $AKARAHOME/src
cd $AKARAHOME/src
hg clone http://bitbucket.org/uche/amara/ amara # You can also clone from http://hg.xml3k.org/amara
cd amara
python setup.py install
cd $AKARAHOME #Do not import/run Amara from its source dir

Then each time you want to go back to the sandbox:

cd $AKARAHOME
source $AKARAHOME/bin/activate

Then start experimenting

python -c "import amara;doc=amara.parse('<a/>');print doc.xml_first_child.xml_qname"

To get updates as they come, change to the Amara directory and...

cd $AKARAHOME/src/amara
hg pull; hg up
python setup.py install
cd $AKARAHOME #Do not import/run Amara from its source dir

All installed; now what?

Check out the: Amara/Tutorial

Amara/Mac (last edited 2011-01-20 18:03:17 by UcheOgbuji)