Installing mercurial on a shared web-hosting account (such as Dreamhost)

I've got a Dreamhost account, they offer oodles of disk space, and I want to set up a mercurial repository. The problem is they don't install mercurial as a system-wide thingy. Further it appears python prefers to have all python extensions installed as system-wide thingies (I don't use python and don't know it's ins and outs and idioms). Since I don't know the python idioms that leaves me to go by the mercurial documentation.

On the mercurial wiki they offer prebuilt packages for various packaging systems (.deb or .rpm etc) and they have an "easy install" method for Any system with modern Python and SetupTools installed. It certainly sounds simple to do

  1. easy_install -U mercurial

Going to the EasyInstall home page we find a that installing this script presumes

  • You are installling to Python's primary site-packages directory
  • You have unrestricted system access on the computer where you are installing.

However the typical shared hosting account doesn't allow access to the site-packages directory. Now what? Reading on installing to Custom Locations does have the answer. Specifically the virtual python method.

Once you run virtual-python.py (downloaded from the above page) it creates directories in your $HOME named lib, include and bin which are set up to add stuff to the system python. You can run the regular system python and it will see the regular system python configuration, and you can run ~/bin/python and it will see the additional stuff you've installed in your local python.

Installing virtual python goes like this:-

  1. wget <a href="http://peak.telecommunity.com/dist/virtual-python.py<br />
  2. python" title="http://peak.telecommunity.com/dist/virtual-python.py<br />
  3. python"><a href="http://peak.telecommunity.com/dist/virtual-python.py">http://peak.telecommunity.com/dist/virtual-python.py</a><br />
  4. python</a> virtual-python.py

This creates ~/bin and ~/lib directories with a shadow copy of python. Once you do this it's helpful to ensure your PATH variable contains ~/bin at the front, a useful step to take since it ensures you can use any command you put there.

Next follow the setuptools setup directions for your platform. For a Linux host I did this:-

  1. wget http:.../setuptools-0.6c11-py2.4.egg
  2. export PYTHONPATH=$HOME/lib/python2.4/site-packages
  3. sh setuptools-0.6c11-py2.4.egg --prefix=~

Setting PYTHONPATH was required because of an error message it gave me. It's helpful to set this environment variable in your login environment.

This step may be useful, or might not be useful. Running setuptools seems to make this step unnecessary.

  1. ~/bin/python ez_setup.py

This sets up the easy installer in your local python. Then going back to the mercurial instructions you can now run the following. It may be required to add "--prefix=~" to this command.

  1. ~/bin/easy_install -U mercurial

Note that this time I prefixed '~/bin/' to the command. It's possible to set this python as the default simply by doing this:-

  1. export PATH=$HOME/bin:${PATH}
  2. or
  3. setenv PATH $HOME/bin:${PATH}

Which command you use depends on your shell, of course. It seems the easy_install script adds this command for you to your login environment scripts. In any case once a 'bin' directory is enabled in your home directory you can of course also use it for other scripts, and they'll be automatically available as commands in your shell.


Comments

Re: Installing mercurial on a shared web-hosting account ...

Hi,

Great post.
The installation of Python can be really helpful for those who need a recent version of Python in their shared hosting.
Your post nicely complete mine about installing Mercurial on Dreamhost: http://sili.co.nz/blog/2009/01/installing-mercurial-on-a-shared-webhosti...

Kind regards.

Richard Lopes

Re: Installing mercurial on a shared web-hosting account ...

I'm setting this up on a new shared hosting account and the above did not work.

The additional required steps (learned from the pages linked above) are

  1. $ vi ~/.pydistutils.cfg
  2. $ cat ~/.pydistutils.cfg
  3. [install]
  4. install_lib = /home/reikiman/python/py-lib
  5. install_scripts = /home/reikiman/python/bin
  6. $ mkdir python/py-lib
  7. $ export PYTHONPATH=/home/reikiman/python/py-lib/
  8. $ python ez_setup.py
  9. $ easy_install -U mercurial

Except the mercurial setup (which mostly worked) failed with

  1. unable to execute gcc: Permission denied
  2. error: Setup script exited with error: command 'gcc' failed with exit status 1
  3. $ gcc
  4. -jailshell: /usr/bin/gcc: Permission denied

I tried your instructions on

I tried your instructions on my hostgator account with no luck. These instructions did work: http://blog.tlensing.org/2010/04/12/installing-mercurial-on-a-shared-web...

Python's development packages...

Thanks for your instructions David but it didn't work for me either. The problem is for your way you need the development packages from Python available on your web-hosting account. Very often that is not the case. So the instructions on http://blog.tlensing.org/2010/04/12/installing-mercurial-on-a-shared-web... worked for me too to get Mercurial running. Thanks anyway!