Date: | 25 February 2009 |
---|---|
Tags: | computing, emacs, python |
Update — my entire Emacs configuration is now public,
not just the little snippet that is shown in this old blog post.
Simply visit my dot Emacs repository on GitHub at the following URL:
https://github.com/brandon-rhodes/dot-emacs
$ sudo easy_install package_urlThis means that his Emacs configuration — which, very generously, he has started maintaining as a project on github so that other people can use it themselves, or branch their own versions — requires root access merely to install. Like Ryan, I also keep my Emacs configuration under version control, so that improvements I check in from one account are easy to check out into all of my other accounts. Although my setup is probably too simple to be interesting as a public project, there is one aspect of it that I should share: unlike Ryan, I use the advanced technology of a virtualenv to hold the Python packages that Emacs needs. The virtual environment lives under my own account, and is easy to create, access, and rebuild, even in the absence of root privileges on a particular machine. Even better, packages that I install or upgrade inside of the virtual environment cannot interfere with Python programs running elsewhere on the system. A “virtual environment” is a little self-contained Python install, whose essential files are copied from your main system Python; no additional compilation is necessary! A virtual environment can be created under any directory on your system. For example, on a Unix system, the default Python probably lives under the /usr directory, and looks like this:
/usr/bin/easy_install # to add new packages
/usr/bin/python # the main executable
/usr/lib/python2.5/ # normal packages
/usr/lib/python2.5/site-packages/ # 3rd party packages
$ virtualenv ~/.emacs/usr
/home/bcr/.emacs/usr/bin/easy_install
/home/bcr/.emacs/usr/bin/python
/home/bcr/.emacs/usr/lib/python2.5/
/home/bcr/.emacs/usr/lib/python2.5/site-packages/
# Brandon's ~/.emacs.d/src/build.sh
# Change to the directory containing this script.
cd $(dirname "$0")
# Clean up directories left over from previous run.
DIRS=(Pymacs-0.23 rope-0.9.2 ropemacs-0.6 pyflakes-0.3.0)
rm -rf ../usr ${DIRS[@]}
# Create the virtualenv.
python2.5 virtualenv.py ../usr
source ../usr/bin/activate
# Unpack the four Python packages that Emacs needs.
tar xvfz Pymacs.tar.gz
tar xvfz rope-0.9.2.tar.gz
tar xvfz ropemacs-0.6.tar.gz
tar xvfz pyflakes-0.3.0.tar.gz
# Install them in "~/.emacs/usr" (the "python2.5" that
# gets called here is the one in the virtualenv, thanks
# to my having sourced its "activate" script up above).
for D in ${DIRS[@]}
do cd $D; python2.5 setup.py install; cd ..; done
# Make fresh pymacs.el symlink from ~/.emacs
rm -f ../pymacs.el
ln -s src/Pymacs-0.23/pymacs.el ../pymacs.el
;; From Brandon's ~/.emacs.d/init.el
(add-to-list 'load-path "~/.emacs.d")
(setenv "PYMACS_PYTHON" "~/.emacs.d/usr/bin/python2.5")