Cheap webhosters can be pretty limiting sometimes in the platforms they run and the software packages on offer, even when you do have shell access. Here’s a quick guide to setting Mercurial up on a shared webhost for use when:
- there is no Python.h available, so you cannot build the C extensions
- you can build only the pure Python modules, which is slower but more compatible
- you have to do all of this in your home directory somewhere
Prerequisites
To build Mercurial plus its documentation (e.g. build all), you need to have the Python doctools package. To most easily install the doctools package, it helps to have the Python easy_install package.
easy_install
It’s best to choose one directory where all of your Python eggs and modules will live. In my case, I chose “~/software”, which means the software directory under my home directory.
12 wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.eggsh setuptools-0.6c11-py2.5.egg --prefix=~/software
The first time you run the setuptools install, it may complain about the installation directory not existing:
123456789101112131415 vilimpoc@funky:~/software$ sh setuptools-0.6c11-py2.5.egg --prefix=~/softwareerror: can't create or remove files in install directoryThe following error occurred while trying to add or remove files in the installation directory:[Errno 2] No such file or directory:'/home/vilimpoc/software/lib/python2.5/site-packages/test-easy-install-12006.pth'The installation directory you specified (via --install-dir, --prefix, orthe distutils default setting) was:/home/vilimpoc/software/lib/python2.5/site-packagesThis directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option).
So create the directory:
12 mkdir -p /home/vilimpoc/software/lib/python2.5/site-packagesexport PYTHONPATH=/home/vilimpoc/software/lib/python2.5/site-packages
Then run setuptools again:
1 sh setuptools-0.6c11-py2.5.egg --prefix=~/software
The second time you should see something like:
1234567891011 Processing setuptools-0.6c11-py2.5.eggRemoving /home/vilimpoc/software/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.eggCopying setuptools-0.6c11-py2.5.egg to /home/vilimpoc/software/lib/python2.5/site-packagessetuptools 0.6c11 is already the active version in easy-install.pthInstalling easy_install script to /home/vilimpoc/software/binInstalling easy_install-2.5 script to /home/vilimpoc/software/binInstalled /home/vilimpoc/software/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.eggProcessing dependencies for setuptools==0.6c11Finished processing dependencies for setuptools==0.6c11vilimpoc@funky:~/software$
Make the easy_install command available by exporting its directory to your PATH:
1 export PATH=${PATH}:/home/vilimpoc/software/bin
Now you can run easy_install from everywhere, but you have to always remember to provide the install prefix you chose for where your python modules should live.
docutils
12345678910111213141516171819202122232425262728293031323334353637 easy_install --prefix=~/software docutilsSearching for docutilsReading http://pypi.python.org/simple/docutils/Reading http://docutils.sourceforge.net/Best match: docutils 0.7Downloading http://prdownloads.sourceforge.net/docutils/docutils-0.7.tar.gz?downloadProcessing docutils-0.7.tar.gzRunning docutils-0.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UeCHaD/docutils-0.7/egg-dist-tmp-LsTUG-warning: no files found matching 'MANIFEST'warning: no previously-included files matching '.cvsignore' found under directory '*'warning: no previously-included files matching '*.pyc' found under directory '*'warning: no previously-included files matching '*~' found under directory '*'warning: no previously-included files matching '.DS_Store' found under directory '*'zip_safe flag not set; analyzing archive contents...docutils.parsers.rst.directives.misc: module references __file__docutils.writers.html4css1.__init__: module references __file__docutils.writers.latex2e.__init__: module references __file__docutils.writers.newlatex2e.__init__: module references __file__docutils.writers.odf_odt.__init__: module references __file__docutils.writers.pep_html.__init__: module references __file__docutils.writers.s5_html.__init__: module references __file__Adding docutils 0.7 to easy-install.pth fileInstalling rst2html.py script to /home/vilimpoc/software/binInstalling rst2latex.py script to /home/vilimpoc/software/binInstalling rst2man.py script to /home/vilimpoc/software/binInstalling rst2newlatex.py script to /home/vilimpoc/software/binInstalling rst2odt.py script to /home/vilimpoc/software/binInstalling rst2odt_prepstyles.py script to /home/vilimpoc/software/binInstalling rst2pseudoxml.py script to /home/vilimpoc/software/binInstalling rst2s5.py script to /home/vilimpoc/software/binInstalling rst2xml.py script to /home/vilimpoc/software/binInstalling rstpep2html.py script to /home/vilimpoc/software/binInstalled /home/vilimpoc/software/lib/python2.5/site-packages/docutils-0.7-py2.5.eggProcessing dependencies for docutilsFinished processing dependencies for docutils
Mercurial
Now that docutils is installed in your private Python packages, you can move on to installing Mercurial.
12 vilimpoc@funky:~/software/mercurial-1.6.3$ make PURE=--pure allvilimpoc@funky:~/software/mercurial-1.6.3$ make PURE=--pure HOME=~/software install-home
Then you just have to move the Mercurial directories into the site-packages directory.
1234567891011121314151617181920212223242526272829303132 vilimpoc@funky:~/software/lib/python2.5$ lshgext mercurial mercurial-unknown.egg-info site-packagesvilimpoc@funky:~/software/lib/python2.5$ mv hgext site-packages/vilimpoc@funky:~/software/lib/python2.5$ mv mercurial site-packages/vilimpoc@funky:~/software/lib/python2.5$ mv mercurial-unknown.egg-info site-packages/vilimpoc@funky:~/software/lib/python2.5$ cd ~vilimpoc@funky:~$ hgMercurial Distributed SCMbasic commands:add add the specified files on the next commitannotate show changeset information by line for each fileclone make a copy of an existing repositorycommit commit the specified files or all outstanding changesdiff diff repository (or selected files)export dump the header and diffs for one or more changesetsforget forget the specified files on the next commitinit create a new repository in the given directorylog show revision history of entire repository or filesmerge merge working directory with another revisionpull pull changes from the specified sourcepush push changes to the specified destinationremove remove the specified files on the next commitserve start stand-alone webserverstatus show changed files in the working directorysummary summarize working directory stateupdate update working directory (or switch revisions)use "hg help" for the full list of commands or "hg -v" for detailsvilimpoc@funky:~$
Using Mercurial
Now you have a fully-functional Mercurial install that you can use, for instance, to locally revision control content in your webdirectories.
e.g. You have a simple website in public_html, you can do something like:
1234 cd ~/public_htmlhg inithg addhg commit
Now your changes will be tracked, how sweet is that?
Thanks man! This is work for me! Very nice.