Differences between revisions 13 and 14
Revision 13 as of 2006-05-25 00:18:45
Size: 3613
Editor: RolandR
Comment: explain when a per user install might be the right thing
Revision 14 as of 2006-05-25 04:08:48
Size: 3702
Editor: RolandR
Comment: Remark in "note" about Suse 9.3 regarding need for python-devel
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
default, in which case you'll need {{{python-dev}}} to install. default, in which case you'll need {{{python-dev}}} to install. Suse 9.3 needs {{{python-devel}}} which is NOT on the DVD - download from Suse required.

Installing Mercurial on Unix-like systems

These instructions apply to Linux distributions, MacOS X, and other Unix variants.

Binary packages are available for some Linux distributions, such as Debian. If one is available for your system, that is the easiest way to install it. However, it may not be the latest version. To follow this tutorial, you should probably install from source as described on this page.

Note: some Linux distributions fail to include bits of distutils by default, in which case you'll need python-dev to install. Suse 9.3 needs python-devel which is NOT on the DVD - download from Suse required.

If your system does not ship with Python, install it first. Version 2.3 or greater is required. You'll also need a C compiler and a 3-way MergeProgram.

Unpacking the source

The necessary first step:

$ tar xvzf mercurial-<ver>.tar.gz
$ cd mercurial-<ver>

Per-user installation (recommended for now)

To install in your home directory (~/bin and ~/lib, actually), run:

$ python setup.py install --home=~
$ export PYTHONPATH=${HOME}/lib/python  # bash syntax, ymmv
$ export PATH=${HOME}/bin:$PATH         # add these to your .bashrc

On some 64-bit systems (but not all), you'll need to use lib64 instead of lib in PYTHONPATH. The rule of thumb is that if /usr/lib64 exists, use lib64, otherwise lib. Besides being conservative for your own system, if you are putting up Mercurial to manage a web site or application that is being hosted for you by an ISP, this is likely the method which will least conflict with your host's environment.

System-wide installation

To install system-wide, you'll need root privileges. It is probably not a good idea to do a system-wide install at the moment, as the project moves so quickly that you'll be endlessly running commands under sudo.

$ python setup.py install   # change python to python2.3 if 2.2 is default

In this example, the addition of option --prefix=/var/hg will keep the Mercurial libraries out of /usr and put them instead where the prefix specifies similar to the way that --home=~ above keeps Mercurial local to a user in the per-user-installation. The PYTHONPATH and PATH will also need to be appropriately adjusted if prefix option is used.

Some notes on C compiler

The C compiler is used for compiling Mercurial's extensions written in C.

Sometimes, Python (actually distutils) may be calling a different C compiler (usually the one used for compiling Python itself) than the one installed on your system. In this case, you can try set the environment variable CC to tell Python to use your favorite C compiler. You may also need to set the environment variable LDSHARED for generating shared objects on some platforms.

<!> the environment variable LDSHARED requires Python 2.4, unfortunately.

Here's an example on installing Mercurial on Solaris 2.6 with ActiveState Python 2.4.1 (compiled with Sun CC) and GCC 2.95.3:

$ CC=gcc LDSHARED='gcc -G' python setup.py install

In our example, the -G option tells GCC to generate shared objects on Solaris, which is equivalent the -shared option on some other platforms. See GCC's manpage for more information on this.

Testing a new install

And finally:

$ hg                                    # test installation, show help

Common problems

If you get complaints about missing modules, you probably haven't set PYTHONPATH correctly.

UnixInstall (last edited 2014-02-09 00:14:56 by PaulBoddie)