Size: 13448
Comment: fix links
|
Size: 13343
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
/!\ ''you probably want the prepackaged Windows version from [[Download]]'' |
/!\ Y''ou probably want the prepackaged Windows version from [[Download|here]].'' |
Line 10: | Line 9: |
When installing Mercurial from source there are two choices. Compile optimized version with C extensions for increased performance or use pure Python alternative. The latter doesn't require C compiler to be present on windows system (and it usually isn't). You would need Python and Mercurial source in either case. 1. Download Python binary such as {{{python-2.6.2.msi}}} from [[http://www.python.org/download/]]. Install it to somewhere you can find later - {{{C:\Python26}}} as default. 2. Download Mercurial source such as {{{mercurial-1.3.tar.gz}}} from [[http://www.selenic.com/mercurial/release/?M=D]]. Unpack it to {{{C:\Mercurial_src}}}. |
When installing Mercurial from source, you have two choices: Compile optimized version with C extensions for increased performance, or use the pure Python method. The latter doesn't require a C compiler to be present on Windows system (which it usually isn't). You'll need Python and Mercurial source in either case. 1. Download Python binary such as {{{Python-2.6.2.msi}}} from http://www.Python.org/download/. Install it to somewhere you can find later - {{{C:\Python26}}} as default. 2. Download Mercurial source such as {{{mercurial-1.3.tar.gz}}} from http://www.selenic.com/mercurial/release/?M=D. Unpack it to {{{C:\Mercurial_src}}}. |
Line 23: | Line 19: |
== 'Standard' procedure for building optimized version == '''Caution:''' Don't use Active Python in [[http://www.activestate.com/activepython/]] or you will probably fail to build Mercurial from source. 3. Download MinGW binary such as {{{MinGW-5.1.4.exe}}} from [[http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780]]. Download it to a writable directory. Install it to {{{C:\MinGW}}} as default, with other default opinions ("Current", and then "min"). |
== "Standard" procedure for building optimized version == '''Caution:''' Don't use Active Python in http://www.activestate.com/activePython/, or you will probably fail to build Mercurial from source. 3. Download the MinGW binary (such as {{{MinGW-5.1.4.exe}}}) from http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780. Download it to a writable directory. Install it to {{{C:\MinGW}}} as default, with other default opinions ("Current", and then "min"). |
Line 34: | Line 26: |
{{{ C:\python26;bla bla bla;C:\MinGW\bin }}} |
C:\Python26;bla bla bla;C:\MinGW\bin |
Line 42: | Line 32: |
{{{ python setup.py build --force -c mingw32 python setup.py install --force --skip-build }}} |
Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build |
Line 48: | Line 35: |
Line 50: | Line 36: |
{{{ C:\Python26\python.exe setup.py --pure build_py -c -d . build_ext -i build_mo --force C:\Python26\python.exe setup.py --pure install --force }}} |
C:\Python26\Python.exe setup.py --pure build_py -c -d . build_ext -i build_mo --force C:\Python26\Python.exe setup.py --pure install --force |
Line 56: | Line 40: |
6. Download KDiff3 such as {{{KDiff3Setup_0.9.95.exe}}} from [[http://sourceforge.net/project/showfiles.php?group_id=58666]]. Install it into {{{C:\Program Files\KDiff3}}} as default. |
6. Download KDiff3 such as {{{KDiff3Setup_0.9.95.exe}}} from http://sourceforge.net/project/showfiles.php?group_id=58666. Install it into {{{C:\Program Files\KDiff3}}} as default. |
Line 62: | Line 44: |
8. Create Mercurial config file {{{ Notepad "C:\Documents and Settings\your_name\Mercurial.ini" }}} |
8. Create Mercurial config file: Notepad "C:\Documents and Settings\[your_name]\Mercurial.ini" Or: Notepad "C:\Users\[your_name]\Mercurial.ini" |
Line 70: | Line 54: |
{{{ [ui] editor = Notepad username = your_name <your_email_address> [merge-tools] kdiff3.priority=-1 kdiff3.args=--L1 base --L2 local --L3 other $base $local $other -o $output kdiff3.regkey=Software\KDiff3 kdiff3.regappend=\kdiff3.exe kdiff3.fixeol=True kdiff3.gui=True }}} 9. (Nice to have) Copy from {{{C:\Python26\Scripts\hg}}} to {{{C:\Python26\hg.py}}}. As {{{C:\Python26}}} is in your PATH env already, you could call hg.py to run Mercurial at any location. As you may installed or will install binary Mercurial or TortoiseHG, you could always call hg.py to run this script version of Mercurial, or call hg which will lead you to the binary version. |
[ui] editor = Notepad username = your_name <your_email_address> [merge-tools] kdiff3.priority=-1 kdiff3.args=--L1 base --L2 local --L3 other $base $local $other -o $output kdiff3.regkey=Software\KDiff3 kdiff3.regappend=\kdiff3.exe kdiff3.fixeol=True kdiff3.gui=True 9. (Nice to have) Copy from {{{C:\Python26\Scripts\hg}}} to {{{C:\Python26\hg.py}}}. As {{{C:\Python26}}} is in your PATH env already, you could call hg.py to run Mercurial at any location. As you may installed or will install binary Mercurial or TortoiseHG, you could always call hg.py to run this script version of Mercurial, or call hg which will lead you to the binary version. |
Line 89: | Line 59: |
Line 91: | Line 60: |
Line 94: | Line 62: |
* a Python interpreter (such as the one from [[http://www.python.org|python.org]], or [[http://www.activestate.com/Products/ActivePython/|ActivePython]]) | * a Python interpreter (such as the one from [[http://www.Python.org|Python.org]], or [[http://www.activestate.com/Products/ActivePython/|ActivePython]]) |
Line 99: | Line 68: |
If you are using [[http://www.python.org|python.org]]'s Python, you will find that the [[http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063|win32 API extensions]] make a huge performance difference when you use the {{{clone}}} command (but see the caveats below about hardlinks on Windows). If you are using Python 2.4, you will also need [[http://starship.python.net/crew/mhammond/win32/Downloads.html|mfc71.dll]]. (These extensions are already shipped as part of [[http://www.activestate.com/Products/ActivePython/|ActivePython]], but Active``Python is not completely open source software.) See [[BuildingWindowsInstaller]] for instructions to build a Mercurial installer. [[BuildingOnWindows]] has some hints about how to build Mercurial on Windows. |
If you are using [[http://www.Python.org|Python.org]]'s Python, you will find that the [[http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063|win32 API extensions]] make a huge performance difference when you use the {{{clone}}} command (but see the caveats below about hardlinks on Windows). If you are using Python 2.4, you will also need [[http://starship.Python.net/crew/mhammond/win32/Downloads.html|mfc71.dll]]. (These extensions are already shipped as part of [[http://www.activestate.com/Products/ActivePython/|ActivePython]], but ActivePython is not completely open source software.) See BuildingWindowsInstaller for instructions to build a Mercurial installer. BuildingOnWindows has some hints about how to build Mercurial on Windows. |
Line 107: | Line 76: |
{{{ python setup.py install --force }}} |
Python setup.py install --force |
Line 112: | Line 80: |
Line 114: | Line 81: |
Line 117: | Line 83: |
By default, Python and Active``Python will look for Microsoft Visual C to compile the extensions, so you have to tell {{{setup.py}}} to use the Ming``W32 compiler instead. You can do this by running {{{ python setup.py build --force -c mingw32 python setup.py install --force --skip-build |
By default, Python and ActivePython will look for Microsoft Visual C to compile the extensions, so you have to tell {{{setup.py}}} to use the MingW32 compiler instead. You can do this by running: {{{ Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build |
Line 125: | Line 89: |
{{{ python setup.py build -f -c mingw32 install -f }}} |
Python setup.py build -f -c mingw32 install -f |
Line 131: | Line 94: |
{{{ msys.exe msysDTK.exe }}} |
msys.exe msysDTK.exe |
Line 137: | Line 98: |
{{{ | |
Line 139: | Line 99: |
}}} | |
Line 144: | Line 104: |
{{{ set PATH=%PATH%;c:\python24;c:\msys\1.0\mingw\bin }}} If you encounter compiler error in Mercurial versions 0.9.2 and up, you may need libpython24.a in PYTHONPATH\libs. If that's the case, you need to: {{{ pexports C:\WINDOWS\system32\python24.dll > python24.def dlltool --dllname C:\WINDOWS\system32\python24.dll --def python24.def --output-lib C:\Python24\libs\libpython24.a }}} Then the above setup.py script should run properly. |
set PATH=%PATH%;c:\Python24;c:\msys\1.0\mingw\bin If you encounter a compiler error in Mercurial versions 0.9.2 and up, you may need libPython24.a in PYTHONPATH\libs. If that's the case, run this command: {{{ pexports C:\WINDOWS\system32\Python24.dll > Python24.def dlltool --dllname C:\WINDOWS\system32\Python24.dll --def Python24.def --output-lib C:\Python24\libs\libPython24.a }}} The above setup.py script should then run properly. |
Line 160: | Line 114: |
Line 163: | Line 116: |
{{{ set PATH=%PATH%;c:\python24;c:\cygwin\bin python setup.py build --force -c mingw32 python setup.py install --force --skip-build }}} |
set PATH=%PATH%;c:\Python24;c:\cygwin\bin Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build |
Line 171: | Line 119: |
If you are going to use MS Visual C++, you need to use the same version of the compiler as the one which was used to build the Python interpreter. For example: * Active``Python 2.3.5 was built with VC6 * Active``Python 2.4.1 was built with VC7.1 * Python 2.4.4 win32 from python.org was built with VC7.1 (Visual Studio 2003) * Python 2.5.4 win32 from python.org was built with VC7.1 (Visual Studio 2003) * Python 2.5.2 amd64 from python.org was built with VC8 (Visual Studio 2005) * Python 2.6.1 (win32/amd64) from python.org were built with VC9 (Visual Studio 2008) It is possible to ''force'' Python to use the compiler that you currently have, even if it's not strictly matching, but since Mercurial 1.3 (more precisely since 7de68012f86e and the introduction of `posixfile` in the osutil.c extension) the resulting Mercurial will crash, probably due to mismatches in the runtime. Note that if you take care of backing out 7de68012f86e and related changes (b6d0fa8c7685 and 835a51e63c5b), then building Mercurial with a different compiler would still work using the DISTUTILS_USE_SDK=1 trick. Refer to a previous version of this wiki page if you really need to build Mercurial this way. |
If you are going to use MS Visual C++, you need to use the same version of the compiler as the one which was used to build the Python interpreter. For example: * ActivePython 2.3.5 was built with VC6 * ActivePython 2.4.1 was built with VC7.1 * Python 2.4.4 win32 from Python.org was built with VC7.1 (Visual Studio 2003) * Python 2.5.4 win32 from Python.org was built with VC7.1 (Visual Studio 2003) * Python 2.5.2 amd64 from Python.org was built with VC8 (Visual Studio 2005) * Python 2.6.1 (win32/amd64) from Python.org were built with VC9 (Visual Studio 2008) It is possible to ''force'' Python to use the compiler that you currently have, even if it's not strictly matching, but since Mercurial 1.3 (more precisely since 7de68012f86e and the introduction of `posixfile` in the osutil.c extension), the resulting Mercurial installation will crash, probably due to mismatches in the runtime. (Note: If you take care of backing out 7de68012f86e and related changes (b6d0fa8c7685 and 835a51e63c5b), then building Mercurial with a different compiler would still work using the DISTUTILS_USE_SDK=1 trick. Refer to a previous version of this wiki page if you really need to build Mercurial this way.) |
Line 193: | Line 133: |
Line 195: | Line 134: |
Line 200: | Line 138: |
If you are running a Windows of the 9x series (Windows 95, 98 or ME), create a file called {{{hg.bat}}} with the following content: {{{ @echo off shift python <path-to-Scripts-folder>\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 }}} For example, if you installed Python in {{{c:\python}}}, the content of the file would be {{{ @echo off shift python c:\python\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 }}} |
If you are running a Windows version of the 9x series (Windows 95, 98, or ME), create a file called {{{hg.bat}}} with the following content: @echo off shift Python <path-to-Scripts-folder>\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 For example, if you installed Python in {{{c:\Python}}}, the content of the file would be @echo off shift Python c:\Python\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 |
Line 216: | Line 148: |
{{{ @python <path-to-Scripts-folder>\hg %* }}} For example, if you installed Python in {{{c:\python}}}, the content of the file would be {{{ @python c:\python\Scripts\hg %* }}} An alternative scheme that works better for some is to search for hg on the PATH. If you are using hg.exe it should work fine. For the python version of hg you should be able to simply rename 'hg' to 'hg.py' and assuming you have the .py extension configured it will be invoked. It is invoked, but there is a long standing redirection bug in Windows, and on XP there are sometimes problems with exit statuses being lost with this form of execution. So the following batch file is a solution -- place it in your PATH and it will find 'hg' without a .py extension in you PATH and invoke it properly: (name the file '''hg.cmd''') {{{ @echo off for /f %%i in ("hg") DO set HGSCRIPT="%%~$PATH:i" if %HGSCRIPT% == "" ( echo Cannot find hg on PATH exit /b 1 ) python %HGSCRIPT% %* }}} An alternative is to add .py to the PATHEXT environment variable. Provided you have .py files set-up to run automatically when invoked, this allows you to run python scripts from the command line without the ending .py. This option also works if you are using UTF-8 in the Windows console (i.e code page 65001) which causes BAT and CMD files to stop working. |
@Python <path-to-Scripts-folder>\hg %* For example, if you installed Python in {{{c:\Python}}}, the content of the file would be @Python c:\Python\Scripts\hg %* An alternative scheme that works better for some is to search for hg on the PATH. If you are using hg.exe it should work fine. For the Python version of hg you should be able to simply rename 'hg' to 'hg.py' and assuming you have the .py extension configured it will be invoked. It is invoked, but there is a long standing redirection bug in Windows, and on XP there are sometimes problems with exit statuses being lost with this form of execution. So the following batch file is a solution -- place it in your PATH and it will find 'hg' without a .py extension in you PATH and invoke it properly: (name the file '''hg.cmd''') @echo off for /f %%i in ("hg") DO set HGSCRIPT="%%~$PATH:i" if %HGSCRIPT% == "" ( echo Cannot find hg on PATH exit /b 1 ) Python %HGSCRIPT% %* An alternative is to add .py to the PATHEXT environment variable. Provided you have .py files set-up to run automatically when invoked, this allows you to run Python scripts from the command line without the ending .py. This option also works if you are using UTF-8 in the Windows console (i.e code page 65001) which causes BAT and CMD files to stop working. |
Line 246: | Line 161: |
Refer to [[http://www.selenic.com/mercurial/hgrc.5.html | this manual page]] for an overview. |
Refer to [[http://www.selenic.com/mercurial/hgrc.5.html|this manual page]] for an overview. |
Line 252: | Line 166: |
Win``Zip7 does not seem to create empty files when extracting from .tar files. But Win``Zip9 is fine. Earlier versions of mercurial had trouble handling tildes in glob patterns on windows. Upgrade if you encounter this problem. |
WinZip7 does not seem to create empty files when extracting from .tar files. But WinZip9 is fine. Earlier versions of mercurial had trouble handling tildes in glob patterns on windows. Upgrade if you encounter this problem. |
Line 261: | Line 172: |
* Install [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|PuTTY]] and follow the instructions in AccessingSshRepositoriesFromWindows. * Install cygwin and OpenSSH and use the cygwin shell where ssh will be automatically in the PATH * Install cygwin and OpenSSH and modify Mercurial.ini to call the cygwin installed ssh executable. * Install git, it has ssh binaries or you can [[attachment:sshbin.zip|download]] and upzip where someplace in the PATH. Edit the Mercurial.ini to have the following entry: {{{ [ui] ssh = C:\cygwin\bin\ssh.exe }}} === Fix the path problem on Windows === If you try to use hg inside a directory that has a 'mercurial' subdirectory, for example when working on the mercurial sources, python may not be able to load the binary modules needed by Mercurial, and you may get a stack trace like: {{{ ... File "C:\projects\hg\mercurial\demandload.py", line 54, in module return object.__getattribute__(self, 'importer').module() File "C:\projects\hg\mercurial\demandload.py", line 30, in module self.fromlist) File "C:\projects\hg\mercurial\mdiff.py", line 9, in ? import struct, bdiff, util, mpatch ImportError: No module named bdiff }}} See the mail list thread "Fix the path problem on Windows..." but essentially Python on Windows ends up with the current directory automatically added to the python search path '''before''' the site libraries. So if you run hg in its own repository python gets confused, and can't find the extensions needed. There is a candidate patch that removes the current directory, but there is an arguably better workaround from K.Thananchayan. Simply add a registry entry (replacing 2.4 with the version of Python) {{{ HKLM/SOFTWARE/Python/PythonCore/2.4/PythonPath/XXX (Default) REG_SZ "YYY" }}} |
1. Install [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|PuTTY]] and follow the instructions here: [[AccessingSshRepositoriesFromWindows|Accessing SSH Repositories From Windows]] 1. Install cygwin and OpenSSH, then use the cygwin shell where ssh will be automatically in the PATH. 1. Install cygwin and OpenSSH, and modify Mercurial.ini to call the cygwin-installed ssh executable. 1. Install git, which has has ssh binaries, or [[attachment:sshbin.zip|download]] and unzip this file someplace in your PATH. Edit the Mercurial.ini file to have the following entry: {{{ [ui] ssh = C:\cygwin\bin\ssh.exe }}} === Fix the PATH problem on Windows === If you try to use hg inside a directory that has a "mercurial" subdirectory (such as when working on the Mercurial sources), Python may not be able to load the binary modules needed by Mercurial, and you may get a stack trace error similar to: ... File "C:\projects\hg\mercurial\demandload.py", line 54, in module return object.__getattribute__(self, 'importer').module() File "C:\projects\hg\mercurial\demandload.py", line 30, in module self.fromlist) File "C:\projects\hg\mercurial\mdiff.py", line 9, in ? import struct, bdiff, util, mpatch ImportError: No module named bdiff See the mail list thread "Fix the path problem on Windows..." but essentially Python on Windows ends up with the current directory automatically added to the Python search path '''before''' the site libraries. So if you run hg in its own repository Python gets confused, and can't find the extensions needed. There is a candidate patch that removes the current directory, but there is an arguably better workaround from K.Thananchayan. Simply add a registry entry (replacing 2.4 with the version of Python) {{{ HKLM/SOFTWARE/Python/PythonCore/2.4/PythonPath/XXX (Default) REG_SZ "YYY" }}} |
Line 303: | Line 194: |
Line 307: | Line 197: |
The default editor for commit messages is 'vi'. The Windows installer creates a mercurial.ini that sets it to notepad. You can set the EDITOR (or HGEDITOR) environment variable to specify your preference or set it in mercurial.ini: {{{ [ui] editor = whatever }}} |
The default editor for commit messages is {{{vi}}}. The Windows installer creates a {{{Mercurial.ini}}} file that sets it to notepad. You can set the EDITOR (or HGEDITOR) environment variable to specify your preference, or set it in {{{Mercurial.ini:}}} {{{ [ui] editor = whatever }}} |
Line 317: | Line 203: |
* Setting the PYTHONPATH for Windows: http://www.spacemonkey.info/pythonpath_for_win.html | * Setting the PYTHONPATH for Windows: http://www.spacemonkey.info/Pythonpath_for_win.html |
Windows Install
You probably want the prepackaged Windows version from here.
In this web page firstly you will find a 'standard' procedure to install and config Mercurial from sources under Windows. It should satisfy you generally. If not, you could continue reading for various tips and references provided by various contributors in history. Some of them are valuable although some of them are a bit out of date.
Contents
Compile and install
When installing Mercurial from source, you have two choices: Compile optimized version with C extensions for increased performance, or use the pure Python method. The latter doesn't require a C compiler to be present on Windows system (which it usually isn't).
You'll need Python and Mercurial source in either case.
1. Download Python binary such as Python-2.6.2.msi from http://www.Python.org/download/. Install it to somewhere you can find later - C:\Python26 as default.
2. Download Mercurial source such as mercurial-1.3.tar.gz from http://www.selenic.com/mercurial/release/?M=D. Unpack it to C:\Mercurial_src.
Caution: Check to make sure you didn't unpack it to C:\Mercurial_src\mercurial-1.3 or similar.
1. "Standard" procedure for building optimized version
Caution: Don't use Active Python in http://www.activestate.com/activePython/, or you will probably fail to build Mercurial from source.
3. Download the MinGW binary (such as MinGW-5.1.4.exe) from http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780. Download it to a writable directory. Install it to C:\MinGW as default, with other default opinions ("Current", and then "min").
4. Add C:\MinGW\bin to PATH env. It should looks like
C:\Python26;bla bla bla;C:\MinGW\bin
Caution: The order is important. Keep it or you will probably fail to build.
5. In Windows command prompt, change dir to C:\Mercurial_src. Then run following commands:
Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build
2. Building pure Python alternative
3. Change dir to C:\Mercurial_src and run following commands:
C:\Python26\Python.exe setup.py --pure build_py -c -d . build_ext -i build_mo --force C:\Python26\Python.exe setup.py --pure install --force
Setup environment
6. Download KDiff3 such as KDiff3Setup_0.9.95.exe from http://sourceforge.net/project/showfiles.php?group_id=58666. Install it into C:\Program Files\KDiff3 as default.
7. Add C:\Program Files\KDiff3 to PATH env.
8. Create Mercurial config file:
Notepad "C:\Documents and Settings\[your_name]\Mercurial.ini"
Or:
Notepad "C:\Users\[your_name]\Mercurial.ini"
Fill in content below into the config file:
[ui] editor = Notepad username = your_name <your_email_address> [merge-tools] kdiff3.priority=-1 kdiff3.args=--L1 base --L2 local --L3 other $base $local $other -o $output kdiff3.regkey=Software\KDiff3 kdiff3.regappend=\kdiff3.exe kdiff3.fixeol=True kdiff3.gui=True
9. (Nice to have) Copy from C:\Python26\Scripts\hg to C:\Python26\hg.py. As C:\Python26 is in your PATH env already, you could call hg.py to run Mercurial at any location. As you may installed or will install binary Mercurial or TortoiseHG, you could always call hg.py to run this script version of Mercurial, or call hg which will lead you to the binary version.
Various tips and references
1. Overview
To install Mercurial from sources under Windows, you need
a Python interpreter (such as the one from Python.org, or ActivePython)
- a C compiler (this is needed to compile some extensions used by Mercurial, so it's needed at setup-time only and not to run Mercurial itself)
- Mercurial's own sources, of course
- a three-way merge program
If you are using Python.org's Python, you will find that the win32 API extensions make a huge performance difference when you use the clone command (but see the caveats below about hardlinks on Windows). If you are using Python 2.4, you will also need mfc71.dll. (These extensions are already shipped as part of ActivePython, but ActivePython is not completely open source software.)
See BuildingWindowsInstaller for instructions to build a Mercurial installer. BuildingOnWindows has some hints about how to build Mercurial on Windows.
This pages describes some issues you may meet when trying to install Mercurial, and how to solve them.
Ideally, you would only need to run
Python setup.py install --force
in the directory where you unpacked the sources, and everything would "just work". The use of -f/--force switch makes sure that any old installation is overwritten.
2. Build tips
2.1. MingW32
2.1.1. Using MingW32
By default, Python and ActivePython will look for Microsoft Visual C to compile the extensions, so you have to tell setup.py to use the MingW32 compiler instead. You can do this by running:
Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build
or more briefly:
Python setup.py build -f -c mingw32 install -f
If you are not familiar with mingw32, you will first need to download and install the following packages, in the order given:
msys.exe msysDTK.exe
Afterwards, download and install the following package, installing it in the directory where you installed the msys package (i.e. c:\msys\1.0\)
MinGW.exe
You can find them at http://www.mingw.org
Then add the Python and mingw directories to your PATH, and run your build from the command prompt:
set PATH=%PATH%;c:\Python24;c:\msys\1.0\mingw\bin
If you encounter a compiler error in Mercurial versions 0.9.2 and up, you may need libPython24.a in PYTHONPATH\libs. If that's the case, run this command:
pexports C:\WINDOWS\system32\Python24.dll > Python24.def dlltool --dllname C:\WINDOWS\system32\Python24.dll --def Python24.def --output-lib C:\Python24\libs\libPython24.a
The above setup.py script should then run properly.
2.1.2. Easier MingW32 based build via Cygwin
It is easier to install MinGW32 via Cygwin as it has a single graphical installer. After installing, mingw32 via Cygwin installer (setup.exe), add cygwin bin directory to the path and follow the mingw32 build instructions. e.g.
set PATH=%PATH%;c:\Python24;c:\cygwin\bin Python setup.py build --force -c mingw32 Python setup.py install --force --skip-build
2.2. MS Visual Studio
If you are going to use MS Visual C++, you need to use the same version of the compiler as the one which was used to build the Python interpreter. For example:
ActivePython 2.3.5 was built with VC6
ActivePython 2.4.1 was built with VC7.1
- Python 2.4.4 win32 from Python.org was built with VC7.1 (Visual Studio 2003)
- Python 2.5.4 win32 from Python.org was built with VC7.1 (Visual Studio 2003)
- Python 2.5.2 amd64 from Python.org was built with VC8 (Visual Studio 2005)
- Python 2.6.1 (win32/amd64) from Python.org were built with VC9 (Visual Studio 2008)
It is possible to force Python to use the compiler that you currently have, even if it's not strictly matching, but since Mercurial 1.3 (more precisely since 7de68012f86e and the introduction of posixfile in the osutil.c extension), the resulting Mercurial installation will crash, probably due to mismatches in the runtime.
(Note: If you take care of backing out 7de68012f86e and related changes (b6d0fa8c7685 and 835a51e63c5b), then building Mercurial with a different compiler would still work using the DISTUTILS_USE_SDK=1 trick. Refer to a previous version of this wiki page if you really need to build Mercurial this way.)
3. Install tips
3.1. Where is my Mercurial?
By default, Mercurial (the executable) gets installed in a Scripts folder under your Python installation folder.
You can create a small batch file in a folder which is present in your path (e.g. your Windows installation folder) to help you launch Mercurial.
If you are running a Windows version of the 9x series (Windows 95, 98, or ME), create a file called hg.bat with the following content:
@echo off shift Python <path-to-Scripts-folder>\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
For example, if you installed Python in c:\Python, the content of the file would be
@echo off shift Python c:\Python\hg %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
Under Windows NT, create a file called hg.cmd with the following content:
@Python <path-to-Scripts-folder>\hg %*
For example, if you installed Python in c:\Python, the content of the file would be
@Python c:\Python\Scripts\hg %*
An alternative scheme that works better for some is to search for hg on the PATH. If you are using hg.exe it should work fine. For the Python version of hg you should be able to simply rename 'hg' to 'hg.py' and assuming you have the .py extension configured it will be invoked. It is invoked, but there is a long standing redirection bug in Windows, and on XP there are sometimes problems with exit statuses being lost with this form of execution. So the following batch file is a solution -- place it in your PATH and it will find 'hg' without a .py extension in you PATH and invoke it properly: (name the file hg.cmd)
@echo off for /f %%i in ("hg") DO set HGSCRIPT="%%~$PATH:i" if %HGSCRIPT% == "" ( echo Cannot find hg on PATH exit /b 1 ) Python %HGSCRIPT% %*
An alternative is to add .py to the PATHEXT environment variable. Provided you have .py files set-up to run automatically when invoked, this allows you to run Python scripts from the command line without the ending .py. This option also works if you are using UTF-8 in the Windows console (i.e code page 65001) which causes BAT and CMD files to stop working.
3.2. Where should I put my initialization/configuration files?
Refer to this manual page for an overview.
Note: For installations of 32-bit Python on 64-bit Windows, the HKLM key should actually be under HKLM/SOFTWARE/Wow6432Node/Mercurial. Put the path to your INI file in the (Default) value that is created when you create the Mercurial key.
3.3. Other miscellaneous issues
WinZip7 does not seem to create empty files when extracting from .tar files. But WinZip9 is fine.
Earlier versions of mercurial had trouble handling tildes in glob patterns on windows. Upgrade if you encounter this problem.
3.3.1. Using the SSH protocol
Three solutions:
Install PuTTY and follow the instructions here: Accessing SSH Repositories From Windows
- Install cygwin and OpenSSH, then use the cygwin shell where ssh will be automatically in the PATH.
- Install cygwin and OpenSSH, and modify Mercurial.ini to call the cygwin-installed ssh executable.
Install git, which has has ssh binaries, or download and unzip this file someplace in your PATH.
Edit the Mercurial.ini file to have the following entry:
[ui] ssh = C:\cygwin\bin\ssh.exe
3.4. Fix the PATH problem on Windows
If you try to use hg inside a directory that has a "mercurial" subdirectory (such as when working on the Mercurial sources), Python may not be able to load the binary modules needed by Mercurial, and you may get a stack trace error similar to:
... File "C:\projects\hg\mercurial\demandload.py", line 54, in module return object.getattribute(self, 'importer').module() File "C:\projects\hg\mercurial\demandload.py", line 30, in module self.fromlist) File "C:\projects\hg\mercurial\mdiff.py", line 9, in ? import struct, bdiff, util, mpatch ImportError: No module named bdiff
See the mail list thread "Fix the path problem on Windows..." but essentially Python on Windows ends up with the current directory automatically added to the Python search path before the site libraries. So if you run hg in its own repository Python gets confused, and can't find the extensions needed. There is a candidate patch that removes the current directory, but there is an arguably better workaround from K.Thananchayan. Simply add a registry entry (replacing 2.4 with the version of Python)
HKLM/SOFTWARE/Python/PythonCore/2.4/PythonPath/XXX (Default) REG_SZ "YYY"
3.5. Hardlinks on Windows
see HardlinkedClones
3.6. Default editor
The default editor for commit messages is vi. The Windows installer creates a Mercurial.ini file that sets it to notepad. You can set the EDITOR (or HGEDITOR) environment variable to specify your preference, or set it in Mercurial.ini:
[ui] editor = whatever
4. External links
Setting the PYTHONPATH for Windows: http://www.spacemonkey.info/Pythonpath_for_win.html