Install alot from cloned repo on Mac OS X

Just a short note on how to install alot from a cloned repository. This might be incomplete since its from memory and I am writing this down since I had to to a reinstall and I had to figure it out again.

You can install alot from homebrew using brew install alot, but I needed to modify the code so the tag autocompletion search the whole tag name for the substring (e.g. typing “cur” would not autocomplete to “@/Current” without changing a default parameter in the code).

So I install notmuch via homebrew:

$ brew install notmuch

then clone pazz/alot:

$ cd parent-dir-to-where-you-want-the-alot-repo
$ git clone https://github.com/pazz/alot.git

I am using pyenv together with pyenv-virtualenv to manage my python versions. These are installed via homebrew as well:

$ brew install pyenv pyenv-virtualenv

If you are just installing pyenv and pyenv-virtualenv now, you’ll need make a change to your .profile and install at least one version of python2 before installing alot from the cloned repository.

Add the following to your .profile and restart your shell (or source ~/.profile it):

# pyenv
# bonus export below that is not needed for alot, but needed
# if you want to use python with e.g. nvim
export PYTHON_CONFIGURE_OPTS="--enable-framework"
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

# pyenv-virtualenv
# another bonus export, not strictly needed, but gets rid of a
# prompt when switching virtual environments
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi

Now install e.g. python 2.7.12 via pyenv:

$ pyenv install 2.7.12

Then create a virtualenv for alot an activate it:

$ pyenv virtualenv alot
$ pyenv activate alot

Finally, before you can install, you need to add the python packages installed by homebrew to your virtual environment:

echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> $PYENV_VIRTUAL_ENV/lib/python2.7/site-packages/homebrew.pth

This adds the file homebrew.pth to your virtualenv site-packages directory which contains a reference to the site-packages directory used by homebrew. Now you can finally install alot from your cloned repository:

$ cd path-to-alot-repo
$ pip install -e ./

pip should see that the notmuch library is avaliable and will not install its own (which I couldn’t get to access the notmuch bindings installed by homebrew). You should now be able to run alot if the correct virtualenv is activated.

# activate the alot virtualenv if you havnt
$ pyenv activate alot

# run alot
$ alot

If you get an error about python not being able to find the shared notmuch library, try pip uninstall notmuch in case pip installed it anyway. Also make sure that you have installed notmuch via brew and that there is a directory named notmuch in /usr/local/lib/python2.7/site-packages (where homebrew installs its python packages).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s