Size: 3374
Comment: per conversation this day with boz__ on IRC
|
Size: 10774
Comment: Python headers
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
== Installing Mercurial on Unix-like systems == These instructions apply to Linux distributions, Mac``OS 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:''' [[Download|binary packages]] are available for most systems! <<TableOfContents>> == Prerequisites == |
Line 8: | Line 8: |
default, in which case you'll need {{{python-dev}}} to install. 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 === |
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.4 or greater is required. You need Python C headers. They may be in package called python-dev or python2.6-dev. You'll also need a C compiler and a 3-way MergeProgram. Building the documentation requires [[http://www.methods.co.nz/asciidoc/|ASCIIDOC]] and [[https://fedorahosted.org/xmlto/|XMLTO]], the latter in turn requires [[http://xmlsoft.org/XSLT/|XSLT]]. You may want to check your Linux distribution for these (and possibly others they make use of). If you don't want to build and install the documentations, substitute "make install-bin" and "make install-home-bin" for "make install" and "make install-home" below. Building the documentation in 1.4 requires [[http://docutils.sourceforge.net/|Docutils]]. == Unpacking the source == |
Line 21: | Line 24: |
=== Per-user installation (recommended for now) === | == Per-user installation == |
Line 26: | Line 30: |
$ python setup.py install --home=~ | $ make install-home # add PYTHON=/path/to/python2.4-or-newer if necessary |
Line 30: | Line 34: |
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}}}. === 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 === |
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. {{{#!wiki tip On some systems, a remote login via `ssh` will not cause `.bashrc` to be invoked. It may therefore be appropriate to specify environment variable definitions in your `.bash_profile` instead (or ensure that your `.bash_profile` sources your `.bashrc` appropriately). This behaviour is explained in the `bash` manual page: for an "interactive login shell", `bash` reads from the user's `.bash_profile`, `.bash_login`, or `.profile` instead of `.bashrc` (which is read for "an interactive shell that is not a login shell"). This seems to contradict the behaviour for remote logins via `rsh` where `.bashrc` does get read. }}} == System-wide installation == To install system-wide, you'll need {{{root}}} privileges. {{{ $ make install }}} or if the default python is older than 2.4, {{{ $ make install PYTHON=/path/to/python2.4 }}} With this method, 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 {{{install-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 in your environment: {{{ $ export PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} # bash/ksh syntax }}} Alternatively, you can also create a wrapper script that sets the {{{PYTHONPATH}}} variable, regardless of the user's environment: {{{ $ mv /var/hg/bin/hg /var/hg/bin/hg.py $ cat > /var/hg/bin/hg <<\EOF #!/bin/sh PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} export PYTHONPATH exec /var/hg/bin/hg.py "$@" EOF }}} If {{{PYTHONPATH}}} is not correctly set, then {{{hg debuginstall}}} will print an error message that says: {{{ ImportError: No module named mercurial }}} or {{{ abort: couldn't find mercurial libraries in [...] (check your install and PYTHONPATH) }}} == 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 symlink the hg script into a directory in your path. == Some notes on C compiler == |
Line 46: | Line 104: |
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 === |
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 63: | Line 113: |
$ hg # test installation, show help }}} === Common problems === |
$ 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 69: | Line 126: |
== Platform Notes == === 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. === OS X === Source installation requires asciidoc and xmlto in order to build documentation. These are easy to install via fink or macports: fink: {{{ $ sudo apt-get install asciidoc xmlto # get the latest binary $ fink install asciidoc xmlto # build from source }}} macports: {{{ $ sudo port install asciidoc xmlto }}} Do one of these before building mercurial. For some people on OS X 10.5, Mercurial fails to run with an error similar to the following: {{{ Traceback (most recent call last): File "/opt/local/bin/hg", line 18, in <module> mercurial.util.set_binary(fp) File "/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 74, in __getattribute__ self._load() File "/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 46, in _load mod = _origimport(head, globals, locals) File "/opt/local/lib/python2.5/site-packages/mercurial/util.py", line 93, in <module> _encoding = locale.getlocale()[1] File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 462, in getlocale return _parse_localename(localename) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 375, in _parse_localename raise ValueError, 'unknown locale: %s' % localename ValueError: unknown locale: UTF-8 }}} This appears to be due to the version of Terminal that comes with OS X 10.5 setting the value of the environment variable LC_CTYPE to a bad value, causing Python to throw. You can work around this problem either by going to Terminal > Preferences... > Settings and unchecking the option "Set LANG environment variable on startup", or else you can set the environment variables LC_ALL and LANG to appropriate values in your `~/.profile` (e.g. add `export LC_ALL=en_US.UTF-8` and `export LANG=en_US.UTF-8`). For more information on the LC_* and LANG variables see `man locale`. === Ubuntu === 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 }}} For generating documentation (done during the installation) you will also have to install the asciidoc and xmlto packages: {{{ sudo apt-get install asciidoc xmlto }}} === SUSE/SLES === In order to build the inotify hgext on SUSE/SLES you may have to edit {{{_inotify.c}}} and change the include line for {{{inotify.h}}} from: {{{ #include <sys/inotify.h> }}} to: {{{ #include <linux/inotify.h> }}} === 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. - I installed it via make install-home, but I had to do some gcc calls myself (it didn't take -xarch and -x03). -ArneBab === Solaris 10 (Sparc) === Initially had some issues attempting to use the sunfreeware packages. The version of Python available from there didn't seem to have md5 enabled. Please note that I'm a bit of a novice with Solaris so if someone knows better then please ammend this note - MichaelAnthon 1. Ensure that the following packages are installed * SUNWopenssl-include * SUNWopenssl-libraries * SUNWzlib * SMCgcc and SMClgcc346 (I had to upgrade to the 3.4.6 version before it would compile cleanly) 1. Build python (using gcc from /usr/sfw and the Solaris assembler and linker from /usr/ccs and libraries from /usr/sfw/lib/, /usr/lib and /usr/local/lib) {{{ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/sfw/lib/:/usr/lib:/usr/local/lib export PATH=$PATH:/usr/ccs/bin:/usr/sfw/bin ./configure --libdir=/usr/sfw/lib/ --libdir=/usr/lib --libdir=/usr/local/lib --includedir=/usr/sfw/include --includedir=/usr/include --includedir=/usr/local/include make make install (as root) }}} 1. Install setuptools from http://pypi.python.org/pypi/setuptools ( /!\ at this point I had to make a symlink from /usr/bin/python to /usr/bin/python2.6, not sure if the python install SHOULD have done that for me) 1. Install Mercurial {{{ /usr/local/bin/easy_install -U mercurial }}} ---- CategoryHowTo |
Note: binary packages are available for most systems!
Contents
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.4 or greater is required. You need Python C headers. They may be in package called python-dev or python2.6-dev. You'll also need a C compiler and a 3-way MergeProgram.
Building the documentation requires ASCIIDOC and XMLTO, the latter in turn requires XSLT. You may want to check your Linux distribution for these (and possibly others they make use of). If you don't want to build and install the documentations, substitute "make install-bin" and "make install-home-bin" for "make install" and "make install-home" below.
Building the documentation in 1.4 requires Docutils.
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:
$ make install-home # add PYTHON=/path/to/python2.4-or-newer if necessary $ 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.
On some systems, a remote login via ssh will not cause .bashrc to be invoked. It may therefore be appropriate to specify environment variable definitions in your .bash_profile instead (or ensure that your .bash_profile sources your .bashrc appropriately).
This behaviour is explained in the bash manual page: for an "interactive login shell", bash reads from the user's .bash_profile, .bash_login, or .profile instead of .bashrc (which is read for "an interactive shell that is not a login shell"). This seems to contradict the behaviour for remote logins via rsh where .bashrc does get read.
System-wide installation
To install system-wide, you'll need root privileges.
$ make install
or if the default python is older than 2.4,
$ make install PYTHON=/path/to/python2.4
With this method, 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 install-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 in your environment:
$ export PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} # bash/ksh syntax
Alternatively, you can also create a wrapper script that sets the PYTHONPATH variable, regardless of the user's environment:
$ mv /var/hg/bin/hg /var/hg/bin/hg.py $ cat > /var/hg/bin/hg <<\EOF #!/bin/sh PYTHONPATH=/var/hg/lib/python2.5/site-packages:${PYTHONPATH} export PYTHONPATH exec /var/hg/bin/hg.py "$@" EOF
If PYTHONPATH is not correctly set, then hg debuginstall will print an error message that says:
ImportError: No module named mercurial
or
abort: couldn't find mercurial libraries in [...] (check your install and PYTHONPATH)
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 symlink the hg script into a directory 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
FreeBSD
FreeBSD provides the 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 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 the pkgsrc documentation for more information on pkgsrc, and how to get, update and use it.
OS X
Source installation requires asciidoc and xmlto in order to build documentation. These are easy to install via fink or macports:
fink:
$ sudo apt-get install asciidoc xmlto # get the latest binary $ fink install asciidoc xmlto # build from source
macports:
$ sudo port install asciidoc xmlto
Do one of these before building mercurial.
For some people on OS X 10.5, Mercurial fails to run with an error similar to the following:
Traceback (most recent call last): File "/opt/local/bin/hg", line 18, in <module> mercurial.util.set_binary(fp) File "/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 74, in __getattribute__ self._load() File "/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py", line 46, in _load mod = _origimport(head, globals, locals) File "/opt/local/lib/python2.5/site-packages/mercurial/util.py", line 93, in <module> _encoding = locale.getlocale()[1] File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 462, in getlocale return _parse_localename(localename) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 375, in _parse_localename raise ValueError, 'unknown locale: %s' % localename ValueError: unknown locale: UTF-8
This appears to be due to the version of Terminal that comes with OS X 10.5 setting the value of the environment variable LC_CTYPE to a bad value, causing Python to throw. You can work around this problem either by going to Terminal > Preferences... > Settings and unchecking the option "Set LANG environment variable on startup", or else you can set the environment variables LC_ALL and LANG to appropriate values in your ~/.profile (e.g. add export LC_ALL=en_US.UTF-8 and export LANG=en_US.UTF-8). For more information on the LC_* and LANG variables see man locale.
Ubuntu
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
For generating documentation (done during the installation) you will also have to install the asciidoc and xmlto packages:
sudo apt-get install asciidoc xmlto
SUSE/SLES
In order to build the inotify hgext on SUSE/SLES you may have to edit _inotify.c and change the include line for inotify.h from:
#include <sys/inotify.h>
to:
#include <linux/inotify.h>
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.
- I installed it via make install-home, but I had to do some gcc calls myself (it didn't take -xarch and -x03). -ArneBab
Solaris 10 (Sparc)
Initially had some issues attempting to use the sunfreeware packages. The version of Python available from there didn't seem to have md5 enabled. Please note that I'm a bit of a novice with Solaris so if someone knows better then please ammend this note - MichaelAnthon
- Ensure that the following packages are installed
- SUNWopenssl-include
- SUNWopenssl-libraries
- SUNWzlib
- SMCgcc and SMClgcc346 (I had to upgrade to the 3.4.6 version before it would compile cleanly)
- Build python (using gcc from /usr/sfw and the Solaris assembler and linker from /usr/ccs and libraries from /usr/sfw/lib/, /usr/lib and /usr/local/lib)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/sfw/lib/:/usr/lib:/usr/local/lib export PATH=$PATH:/usr/ccs/bin:/usr/sfw/bin ./configure --libdir=/usr/sfw/lib/ --libdir=/usr/lib --libdir=/usr/local/lib --includedir=/usr/sfw/include --includedir=/usr/include --includedir=/usr/local/include make make install (as root)
Install setuptools from http://pypi.python.org/pypi/setuptools (
at this point I had to make a symlink from /usr/bin/python to /usr/bin/python2.6, not sure if the python install SHOULD have done that for me)
- Install Mercurial
/usr/local/bin/easy_install -U mercurial