Differences between revisions 18 and 20 (spanning 2 versions)
Revision 18 as of 2010-10-15 22:26:48
Size: 6942
Editor: abuehl
Comment:
Revision 20 as of 2015-08-03 14:35:16
Size: 11393
Editor: rcl
Comment: add section numbers and ToC
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#pragma section-numbers 2
Line 4: Line 6:
Mercurial is mostly programmed in Python (http://www.python.org/). The Python sources don't need a compilation step, but a few Mercurial modules are programmed in C: base85.c, bdiff.c, diffhelpers.c, mpatch.c and osutil.c (http://selenic.com/repo/hg/file/tip/mercurial/). These must be compiled with a C-compiler. Mercurial is mostly programmed in Python (http://www.python.org/). The Python sources don't need a compilation step, but a few Mercurial modules are programmed in C: `base85.c`, `bdiff.c`, `diffhelpers.c`, `mpatch.c` and `osutil.c` (http://selenic.com/repo/hg/file/tip/mercurial/). These must be compiled with a C-compiler.
Line 6: Line 8:
The steps below worked on a Windows XP SP2, that had a Microsoft Visual C++ installed, and on Windows XP SP2, with mingw installed. <<TableOfContents>>
Line 8: Line 10:
 . {i} The bug tracker entry "windows installation requires MS C compiler" at http://www.selenic.com/mercurial/bts/issue1109 has some hints about using the free mingw port of the gcc compiler instead. == Common Steps ==
=== Installing Python ===
You will need to install Python to build Mercurial. Go to https://www.python.org/downloads/windows/ and download an appropriate MSI installer.
Line 10: Line 14:
Install Python 2.5, available from http://www.python.org/download/windows/ You almost certainly want the most recent Python 2.7 version. These instructions assume you are using version 2.7.
Line 12: Line 16:
Default install path is C:\Python25. Best leave it at that. Installers come in x86 and x86-64 flavors (32 and 64 bit). It doesn't matter which version you use. But this will impact how the build is performed later.
Line 14: Line 18:
Get the Mercurial sources (assuming you already have a working "hg" installed, see for example http://mercurial.berkwood.com/) Quick link: [[https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi|Python 2.7.10 x86-64 MSI installe]]r.

Follow the instructions in the installer. The default install path is C:\python27. These instructions will assume this default is used.

=== Fetch Mercurial Source Code ===
You'll need a copy of the Mercurial source code to build it. If you have TortoiseHg or Mercurial installed already, simply clone the repository:
Line 17: Line 26:
>cd C:\tmp\repos
>
hg clone http://selenic.com/repo/hg mercurial
> hg clone https://selenic.com/repo/hg
Line 20: Line 28:
See DeveloperRepos for other common repositories (the most other interesting one is the CrewRepository). Or, obtain a source archive from https://mercurial.selenic.com/release/
Line 22: Line 30:
Mercurial uses the "Python Distribution Utilities (Distutils)" install process, which also covers building of the extension modules (the files written in C-Code). See http://docs.python.org/inst/inst.html in the Python docs at http://docs.python.org/index.html. == Install a Compiler ==
Mercurial contains Python C extensions that drastically boost performance. While Mercurial can be built without C extensions, it isn't the full Mercurial experience, so installing a C compiler to build Mercurial is highly recommended.
Line 24: Line 33:
The first step is doing a {{{python setup.py build}}} at the top level directory of the Mercurial package. If using mingw, a setup.cfg needs to be created which directs setuptools to use it: There are a few options for compilers.

=== Microsoft Visual C++ Compiler for Python 2.7 ===
If you want to use Microsoft's compiler, you will need to download and install [[http://www.microsoft.com/en-us/download/details.aspx?id=44266|Microsoft Visual C++ Compiler for Python 2.7]].

'''This is required even if you have Visual Studio already installed.'''

You need to install a special compiler package because Python 2.7 itself is built with an old version of Visual Studio and Python C extensions need to be built with the same compiler Python was built with.

By default, the Microsoft Visual C++ Compiler for Python 2.7 installer will install things inside your user directory. This is a little odd for Windows installers. But it shouldn't be a problem. The aforementioned link contains install instructions for installing the package globally.

=== mingw ===
It is technically possible to use the mingw open source compiler.

TODO: document how to obtain the mingw compiler.

Mercurial defaults to using the Microsoft compiler. To change this default, edit the setup.cfg file in the hg source directory to contain the following:
Line 27: Line 52:
cd mercurial
echo
[build] > setup.cfg
echo compiler=mingw32 >> setup.cfg
[build]
compiler=mingw32
Line 31: Line 55:
Line 37: Line 60:
Line 38: Line 62:
>cd c:\python\libs
>pexports c:\windows\system32\python26.dll > python26.def
>dlltool -C -d python26.def -l libpython26.a
>nm libpython26.a
cd c:\python\libs
pexports c:\windows\system32\python26.dll > python26.def
dlltool -C -d python26.def -l libpython26.a
nm libpython26.a
Line 46: Line 70:
{{{
>cd mercurial
>python setup.py build
running build
running build_py
creating build
creating build\lib.win32-2.5
creating build\lib.win32-2.5\mercurial
copying mercurial\ancestor.py -> build\lib.win32-2.5\mercurial
copying mercurial\archival.py -> build\lib.win32-2.5\mercurial
copying mercurial\bundlerepo.py -> build\lib.win32-2.5\mercurial
...
building 'mercurial.mpatch' extension
creating build\temp.win32-2.5
creating build\temp.win32-2.5\Release
creating build\temp.win32-2.5\Release\mercurial
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -IC:\Python25\include -IC:\Python25\PC /Tcmercurial/mpatch.c /Fobuild\temp.win32-2.5\Release\mercurial/mpatch.obj mpatch.c
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python25\libs /LIBPATH:C:\Python25\PCBuild /EXPORT:initmpatch build\temp.win32-2.5\Release\mercurial/mpatch.obj /OUT:build\lib.win32-2.5\mercurial\mpatch.pyd /IMPLIB:build\temp.win32-2.5\Release\mercurial\mpatch.lib
   Creating library build\temp.win32-2.5\Release\mercurial\mpatch.lib and object build\temp.win32-2.5\Release\mercurial\mpatch.exp
...
running build_scripts
creating build\scripts-2.5
copying and adjusting hg -> build\scripts-2.5
}}}
In the above example, Python found and used an installed Microsoft C compiler. The C-source files are compiled and linked into windows dll files using the file extension ".pyd". If the above step fails, you can find some additional tips in WindowsInstall. See also "[[http://docs.python.org/ext/ext.html|Extending and Embedding the Python Interpreter]]" and the more specific "[[http://docs.python.org/ext/building-on-windows.html|Building C and C++ Extensions on Windows]]" in the Python docs.
== Start a Command Prompt ==
To build Mercurial, you'll need to open a command prompt with an appropriate build environment. The steps for doing this vary depending on the compiler used.
Line 72: Line 73:
== Global install ==
Execute {{{python setup.py install}}}
=== For Visual Studio ===
In the Windows Start Menu, navigate to ''Programs -> Microsoft Visual C++ Compiler Package for Python 2.7''. On Windows 10, search for "Visaul C++ 2008".

Launch either the ''Visual C++ 2008 32-bit Command Prompt'' or ''Visual C++ 2008 64-bit Command Prompt'' depending on whether you have the 32-bit or 64-bit version of Python installed.

You will need to export some variables to make Mercurial's build environment happy, per [[http://stackoverflow.com/questions/26140192/microsoft-visual-c-compiler-for-python-2-7|this StackOverflow question]]:
Line 76: Line 81:
> python setup.py install
running install
running build
running build_py
running build_ext
running build_scripts
running install_lib
copying build\lib.win32-2.5\hgext\acl.py -> C:\Python25\Lib\site-packages\hgext
...
copying build\lib.win32-2.5\mercurial\ancestor.py -> C:\Python25\Lib\site-packages\mercurial
...
byte-compiling C:\Python25\Lib\site-packages\hgext\acl.py to acl.pyc
...
byte-compiling C:\Python25\Lib\site-packages\mercurial\ancestor.py to ancestor.pyc
...
running install_scripts
copying build\scripts-2.5\hg -> C:\Python25\Scripts
running install_data
creating C:\Python25\Lib\site-packages\mercurial\templates
copying templates\changelog.tmpl -> C:\Python25\Lib\site-packages\mercurial\templates
copying templates\changelogentry.tmpl -> C:\Python25\Lib\site-packages\mercurial\templates
...
running install_egg_info
Writing C:\Python25\Lib\site-packages\mercurial-fb259a3572e9-py2.5.egg-info
Line 101: Line 82:
This installs hg in C:\Python25\Scripts: === For mingw ===
TODO

== Building ==
Once you have a build environment activated, you should be able to build Mercurial!

All build steps are performed by executing setup.py with Python.

From a Visual Studio command prompt, this looks something like:
Line 104: Line 93:
> python C:\Python25\Scripts\hg version
Mercurial Distributed SCM (version fb259a3572e9)
c:\Python27\python.exe setup.py
}}}
From a mingw shell, this loops something like:
Line 107: Line 97:
Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others {{{
python setup.py
}}}
Assuming we're using the Visual C++ environment, here is what a build may look like:

{{{
> c:\Python27\python.exe setup.py build
running build
running build_mo
warning: hgbuildmo: could not find msgfmt executable, no translations will be built

running build_ext
building 'mercurial.base85' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\mercurial
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\dev\Python27\include -Ic:\dev\Python27\PC /Tcmercurial/base85.c /Fobuild\temp.win-amd64-2.7\Release\mercurial/base85.obj
base85.c
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\mercurial
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\dev\Python27\libs /LIBPATH:c:\dev\Python27\PCbuild\amd64 /EXPORT:initbase85 build\temp.win-amd64-2.7\Release\mercurial/base85.obj /OUT:build\lib.win-amd64-2.7\mercurial\base85.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\mercurial\base85.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\mercurial\base85.pyd.manifest
base85.obj : warning LNK4197: export 'initbase85' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\mercurial\base85.lib and object build\temp.win-amd64-2.7\Release\mercurial\base85.exp
building 'mercurial.bdiff' extension
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\dev\Python27\include -Ic:\dev\Python27\PC /Tcmercurial/bdiff.c /Fobuild\temp.win-amd64-2.7\Release\mercurial/bdiff.obj
bdiff.c
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\dev\Python27\libs /LIBPATH:c:\dev\Python27\PCbuild\amd64 /EXPORT:initbdiff build\temp.win-amd64-2.7\Release\mercurial/bdiff.obj /OUT:build\lib.win-amd64-2.7\mercurial\bdiff.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\mercurial\bdiff.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\mercurial\bdiff.pyd.manifest
bdiff.obj : warning LNK4197: export 'initbdiff' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\mercurial\bdiff.lib and object build\temp.win-amd64-2.7\Release\mercurial\bdiff.exp
...
running build_py
copying mercurial\ancestor.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\archival.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bookmarks.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\branchmap.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bundle2.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bundlerepo.py -> build\lib.win-amd64-2.7\mercurial
...
copying mercurial\templates\static\style-paper.css -> build\lib.win-amd64-2.7\mercurial\templates\static
copying mercurial\templates\static\style.css -> build\lib.win-amd64-2.7\mercurial\templates\static
running build_scripts
creating build\scripts-2.7
copying and adjusting hg -> build\scripts-2.7
copying contrib\win32\hg.bat -> build\scripts-2.7
}}}
n the above example, Python found and used an installed Microsoft C compiler. The C-source files are compiled and linked into windows dll files using the file extension ".pyd". If the above step fails, you can find some additional tips in WindowsInstall. See also "[[http://docs.python.org/ext/ext.html|Extending and Embedding the Python Interpreter]]" and the more specific "[[http://docs.python.org/ext/building-on-windows.html|Building C and C++ Extensions on Windows]]" in the Python docs.

=== Local Builds ===
If you are hacking on the Mercurial source code, you'll want to perform a local, in-place build. In this build mode, files are installed directly in the source directory so you can run Mercurial directly from the source directory. The instructions in this section are essentially copied from the make local target from the Makefile (make is not always available on Windows).

{{{
> c:\Python27\python.exe setup.py build_py -c -d . build_ext -i build_hgexe -i build_mo
}}}
This is essentially 4 commands in one: build_py, build_ext, build_hgexe, build_mo.

''build_py -c -d .'' says to build Python source files, producing .pyc files (-c) and building into the current directory (-d .).

''build_exe -i'' says to build Python C extensions, compiling them in place (-i).

''build_hgexe -i'' says to build the hg.exe wrapper program, compiling it in place (-i).

build_mo says to build some translation databases. (You can probably omit this for many developer workflows.) Also, the default Python install won't be able to build these files because it requires the ''msgfmt ''executable.

If the build completes successfully, there should be a hg.exe in the source directory and you should be able to run it:

{{{
> hg.exe --version
Mercurial Distributed SCM (version 3.5+2-79f0cb97d753)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2015 Matt Mackall and others
Line 111: Line 172:
== Local install for testing/development ==
If you want to have a locally ready to run Mercurial (for example for testing your patches, etc.), you can use the following batch file (named it "build-win32-2.5.cmd"):
For developers, we recommend creating a .bat file with the above setup.py command so you can quickly build Mercurial.

== Global Install ==
To install Mercurial into your global Python installation, use the install command from setup.py:
Line 115: Line 178:
del mercurial\*.pyd
rd /S /Q build
python setup.py build
copy build\lib.win32-2.5\mercurial\*.pyd mercurial
> c:\Python27\python.exe setup.py install
Line 120: Line 180:
Run it from the working directory of your cloned repo. This will copy the compiled C modules (the *.pyd files) into the {{{mercurial}}} directory, giving you a ready to run local hg command. Then, you should be able to execute c:\Python27\Scripts\hg.exe.

How to Build Mercurial on Windows

This how-to is intended to give some hints about how to build Mercurial on Windows from the Mercurial sources. If you don't intend to fiddle with the sources, then simply use a pre-built binary package for Windows (for example TortoiseHg, or http://mercurial.berkwood.com/, see Download). If you want to build an installer or Py2exe distribution, see BuildingWindowsInstaller.

Mercurial is mostly programmed in Python (http://www.python.org/). The Python sources don't need a compilation step, but a few Mercurial modules are programmed in C: base85.c, bdiff.c, diffhelpers.c, mpatch.c and osutil.c (http://selenic.com/repo/hg/file/tip/mercurial/). These must be compiled with a C-compiler.

1. Common Steps

1.1. Installing Python

You will need to install Python to build Mercurial. Go to https://www.python.org/downloads/windows/ and download an appropriate MSI installer.

You almost certainly want the most recent Python 2.7 version. These instructions assume you are using version 2.7.

Installers come in x86 and x86-64 flavors (32 and 64 bit). It doesn't matter which version you use. But this will impact how the build is performed later.

Quick link: Python 2.7.10 x86-64 MSI installer.

Follow the instructions in the installer. The default install path is C:\python27. These instructions will assume this default is used.

1.2. Fetch Mercurial Source Code

You'll need a copy of the Mercurial source code to build it. If you have TortoiseHg or Mercurial installed already, simply clone the repository:

> hg clone https://selenic.com/repo/hg

Or, obtain a source archive from https://mercurial.selenic.com/release/

2. Install a Compiler

Mercurial contains Python C extensions that drastically boost performance. While Mercurial can be built without C extensions, it isn't the full Mercurial experience, so installing a C compiler to build Mercurial is highly recommended.

There are a few options for compilers.

2.1. Microsoft Visual C++ Compiler for Python 2.7

If you want to use Microsoft's compiler, you will need to download and install Microsoft Visual C++ Compiler for Python 2.7.

This is required even if you have Visual Studio already installed.

You need to install a special compiler package because Python 2.7 itself is built with an old version of Visual Studio and Python C extensions need to be built with the same compiler Python was built with.

By default, the Microsoft Visual C++ Compiler for Python 2.7 installer will install things inside your user directory. This is a little odd for Windows installers. But it shouldn't be a problem. The aforementioned link contains install instructions for installing the package globally.

2.2. mingw

It is technically possible to use the mingw open source compiler.

TODO: document how to obtain the mingw compiler.

Mercurial defaults to using the Microsoft compiler. To change this default, edit the setup.cfg file in the hg source directory to contain the following:

[build]
compiler=mingw32

For mingw32 using python built using Microsoft Visual Studio (If you have downloaded python installer from main python site or activestate, they are built using MS Visual Studio), you need to create an import library (archive file) for the GCC (Mingw32) toolset:

  • Make sure you read the instructions on creating a GCC compatible import archive from a MSVC built DLL

  • Download the prerequisites "pexports" and "dlltool" and make sure they are in the PATH
  • Assuming the python interpreter is installed under "c:\python" and you are using python 2.6 (if different, change accordingly)

cd c:\python\libs
pexports c:\windows\system32\python26.dll > python26.def
dlltool -C -d python26.def -l libpython26.a
nm libpython26.a
  • The last command "nm" should show you the exported symbols with "I" (as import symbol)
  • If for some reason the above step does not work when you try to build "hg" (undefined symbol error due to extra "_"), try editing the "python26.def" file and remove the string "DATA" and rerun the "dlltool"

3. Start a Command Prompt

To build Mercurial, you'll need to open a command prompt with an appropriate build environment. The steps for doing this vary depending on the compiler used.

3.1. For Visual Studio

In the Windows Start Menu, navigate to Programs -> Microsoft Visual C++ Compiler Package for Python 2.7. On Windows 10, search for "Visaul C++ 2008".

Launch either the Visual C++ 2008 32-bit Command Prompt or Visual C++ 2008 64-bit Command Prompt depending on whether you have the 32-bit or 64-bit version of Python installed.

You will need to export some variables to make Mercurial's build environment happy, per this StackOverflow question:

3.2. For mingw

TODO

4. Building

Once you have a build environment activated, you should be able to build Mercurial!

All build steps are performed by executing setup.py with Python.

From a Visual Studio command prompt, this looks something like:

c:\Python27\python.exe setup.py

From a mingw shell, this loops something like:

python setup.py

Assuming we're using the Visual C++ environment, here is what a build may look like:

> c:\Python27\python.exe setup.py build
running build
running build_mo
warning: hgbuildmo: could not find msgfmt executable, no translations will be built

running build_ext
building 'mercurial.base85' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\mercurial
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\dev\Python27\include -Ic:\dev\Python27\PC /Tcmercurial/base85.c /Fobuild\temp.win-amd64-2.7\Release\mercurial/base85.obj
base85.c
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\mercurial
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\dev\Python27\libs /LIBPATH:c:\dev\Python27\PCbuild\amd64 /EXPORT:initbase85 build\temp.win-amd64-2.7\Release\mercurial/base85.obj /OUT:build\lib.win-amd64-2.7\mercurial\base85.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\mercurial\base85.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\mercurial\base85.pyd.manifest
base85.obj : warning LNK4197: export 'initbase85' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\mercurial\base85.lib and object build\temp.win-amd64-2.7\Release\mercurial\base85.exp
building 'mercurial.bdiff' extension
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\dev\Python27\include -Ic:\dev\Python27\PC /Tcmercurial/bdiff.c /Fobuild\temp.win-amd64-2.7\Release\mercurial/bdiff.obj
bdiff.c
C:\Users\gps\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\x86_amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\dev\Python27\libs /LIBPATH:c:\dev\Python27\PCbuild\amd64 /EXPORT:initbdiff build\temp.win-amd64-2.7\Release\mercurial/bdiff.obj /OUT:build\lib.win-amd64-2.7\mercurial\bdiff.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\mercurial\bdiff.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\mercurial\bdiff.pyd.manifest
bdiff.obj : warning LNK4197: export 'initbdiff' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\mercurial\bdiff.lib and object build\temp.win-amd64-2.7\Release\mercurial\bdiff.exp
...
running build_py
copying mercurial\ancestor.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\archival.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bookmarks.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\branchmap.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bundle2.py -> build\lib.win-amd64-2.7\mercurial
copying mercurial\bundlerepo.py -> build\lib.win-amd64-2.7\mercurial
...
copying mercurial\templates\static\style-paper.css -> build\lib.win-amd64-2.7\mercurial\templates\static
copying mercurial\templates\static\style.css -> build\lib.win-amd64-2.7\mercurial\templates\static
running build_scripts
creating build\scripts-2.7
copying and adjusting hg -> build\scripts-2.7
copying contrib\win32\hg.bat -> build\scripts-2.7

n the above example, Python found and used an installed Microsoft C compiler. The C-source files are compiled and linked into windows dll files using the file extension ".pyd". If the above step fails, you can find some additional tips in WindowsInstall. See also "Extending and Embedding the Python Interpreter" and the more specific "Building C and C++ Extensions on Windows" in the Python docs.

4.1. Local Builds

If you are hacking on the Mercurial source code, you'll want to perform a local, in-place build. In this build mode, files are installed directly in the source directory so you can run Mercurial directly from the source directory. The instructions in this section are essentially copied from the make local target from the Makefile (make is not always available on Windows).

> c:\Python27\python.exe setup.py build_py -c -d . build_ext -i build_hgexe -i build_mo

This is essentially 4 commands in one: build_py, build_ext, build_hgexe, build_mo.

build_py -c -d . says to build Python source files, producing .pyc files (-c) and building into the current directory (-d .).

build_exe -i says to build Python C extensions, compiling them in place (-i).

build_hgexe -i says to build the hg.exe wrapper program, compiling it in place (-i).

build_mo says to build some translation databases. (You can probably omit this for many developer workflows.) Also, the default Python install won't be able to build these files because it requires the msgfmt executable.

If the build completes successfully, there should be a hg.exe in the source directory and you should be able to run it:

> hg.exe --version
Mercurial Distributed SCM (version 3.5+2-79f0cb97d753)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2015 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For developers, we recommend creating a .bat file with the above setup.py command so you can quickly build Mercurial.

5. Global Install

To install Mercurial into your global Python installation, use the install command from setup.py:

> c:\Python27\python.exe setup.py install

Then, you should be able to execute c:\Python27\Scripts\hg.exe.


CategoryWindows CategoryHowTo CategoryDeveloper

BuildingOnWindows (last edited 2019-01-28 04:09:12 by MattHarbison)