Differences between revisions 1 and 25 (spanning 24 versions)
Revision 1 as of 2005-08-26 00:57:53
Size: 1980
Editor: waste
Comment:
Revision 25 as of 2007-03-13 15:51:24
Size: 5210
Editor: sca-ea-fw-1
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Installing Mercurial on Unix-like systems == '''Note:''' BinaryPackages are available for most systems!
Line 3: Line 3:
These instructions apply to Linux distributions, Mac``OS X, and other Unix variants. [[TableOfContents]]
Line 5: Line 5:
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. == Prerequisites ==
Line 7: Line 7:
'''Note''': some Linux distributions fail to include bits of ''distutils'' by
default, in which case you'll need ''python-dev'' to install.
'''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. FreeBSD users please see the note below.
Line 10: Line 10:
If your system does not ship with Python, install it first. Version 2.2 or greater is required. You'll also need a C compiler and a 3-way MergeProgram. 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.
Line 12: Line 12:

=
== Unpacking the source ===
== Unpacking the source ==
Line 22: Line 21:
=== Per-user installation (recommended for now) === == Per-user installation ==
Line 24: Line 23:
To install in your home directory (''~/bin'' and ''~/lib'', actually), run: To install in your home directory ({{{~/bin}}} and {{{~/lib}}}, actually), run:
Line 27: Line 26:
$ python2.3 setup.py install --home=~ $ python setup.py install --home=~
Line 32: Line 31:
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''. 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.
Line 34: Line 33:
=== System-wide installation === == System-wide installation ==
Line 36: Line 35:
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''. To install system-wide, you'll need {{{root}}} privileges.
Line 42: Line 41:
=== Testing a new install === 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.

For instance, using Python 2.5, and with {{{--prefix=/var/hg}}}, you will need to set {{{PYTHONPATH}}} as follows:

{{{
$ export PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} # bash/ksh syntax
}}}

If {{{PYTHONPATH}}} is not correctly set, then {{{hg debuginstall}}} will print an error message that says:

{{{
ImportError: No module named mercurial
}}}

== Build directory installation ==

If you'd like to run development versions of Mercurial directly out of an hg repository, do:

{{{
$ make local
}}}

This will build Mercurial's extensions in-place. Then, simply put the hg script in your path.

== 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.

With Python 2.4, you may want to set the environment variable '''LDSHARED''' for generating shared objects on some platforms.

== Testing a new install ==
Line 47: Line 78:
$ hg # test installation, show help $ hg debuginstall # sanity-test the install
Checking encoding (UTF-8)...
Checking extensions...
Checking templates...
Checking patch...
Checking merge helper...
Checking commit editor...
Checking username...
No problems detected
Line 50: Line 89:
=== Common problems === If you get complaints about missing modules, you probably haven't set
{{{PYTHONPATH}}} correctly.
Line 52: Line 92:
If you get complaints about missing modules, you probably haven't set
''PYTHONPATH'' correctly.
== Platform Notes ==

=== Solaris ===

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.

=== FreeBSD ===

FreeBSD provides the [http://www.freebsd.org/ports/ Ports System] to easily install and manage applications. To install mercurial on FreeBSD, use the port (typically found in {{{/usr/ports/devel/mercurial}}}), or install and use the {{{portinstall}}} tool. Read [http://www.freebsd.org/ports/updating.html Updating FreeBSD Ports] to make certain you have the most recent ported version of mercurial and all dependent packages.

=== NetBSD ===

NetBSD's pkgsrc system provides a package for mercurial in pkgsrc/devel/mercurial. To install it, run:
{{{
$ cd /usr/pkgsrc/devel/mercurial
$ make install
}}}
See [http://www.NetBSD.org/Documentation/pkgsrc/ the pkgsrc documentation] for more information on pkgsrc, and how to get, update and use it.

=== Ubuntu installation from source ===

In order to build mercurial on Ubuntu Dapper 6.06, it is first necessary to install gcc, the standard libraries, and the python header libraries. This can be done with the following command:

{{{
sudo apt-get install build-essential gcc python-dev
}}}

A system wide installation seems more reliable as Ubuntu does not read in .bashrc when invoked over ssh and cannot find per-user installed hg.

Note: BinaryPackages are available for most systems!

TableOfContents

Prerequisites

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. FreeBSD users please see the note below.

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

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.

$ 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.

For instance, using Python 2.5, and with --prefix=/var/hg, you will need to set PYTHONPATH as follows:

$ export PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} # bash/ksh syntax

If PYTHONPATH is not correctly set, then hg debuginstall will print an error message that says:

ImportError: No module named mercurial

Build directory installation

If you'd like to run development versions of Mercurial directly out of an hg repository, do:

$ make local

This will build Mercurial's extensions in-place. Then, simply put the hg script in your path.

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.

With Python 2.4, you may want to set the environment variable LDSHARED for generating shared objects on some platforms.

Testing a new install

And finally:

$ hg debuginstall   # sanity-test the install
Checking encoding (UTF-8)...
Checking extensions...
Checking templates...
Checking patch...
Checking merge helper...
Checking commit editor...
Checking username...
No problems detected

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

Platform Notes

Solaris

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.

FreeBSD

FreeBSD provides the [http://www.freebsd.org/ports/ Ports System] to easily install and manage applications. To install mercurial on FreeBSD, use the port (typically found in /usr/ports/devel/mercurial), or install and use the portinstall tool. Read [http://www.freebsd.org/ports/updating.html Updating FreeBSD Ports] to make certain you have the most recent ported version of mercurial and all dependent packages.

NetBSD

NetBSD's pkgsrc system provides a package for mercurial in pkgsrc/devel/mercurial. To install it, run:

$ cd /usr/pkgsrc/devel/mercurial
$ make install

See [http://www.NetBSD.org/Documentation/pkgsrc/ the pkgsrc documentation] for more information on pkgsrc, and how to get, update and use it.

Ubuntu installation from source

In order to build mercurial on Ubuntu Dapper 6.06, it is first necessary to install gcc, the standard libraries, and the python header libraries. This can be done with the following command:

sudo apt-get install build-essential gcc python-dev

A system wide installation seems more reliable as Ubuntu does not read in .bashrc when invoked over ssh and cannot find per-user installed hg.

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