Differences between revisions 4 and 55 (spanning 51 versions)
Revision 4 as of 2012-01-02 00:21:30
Size: 4903
Comment: Describe MSYS testing
Revision 55 as of 2016-10-25 12:24:19
Size: 6982
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
The package can be found [[http://mercurial.selenic.com/release/windows/hackable/|here]]. Simply download, unzip, and run the included hg.exe. This package will not interfere with your existing Mercurial or Python installation. The package can be found [[https://mercurial-scm.org/release/windows/hackable/|here]]. Simply download, unzip, and run the included hg.exe. This package will not interfere with your existing Mercurial or Python installation.

Note: The file `mercurial-2.6-hackable.zip` needs the following bugfix: The directory `hg-python26` must be renamed to `hg-python`. Otherwise you will see the error message `abort: failed to load Python DLL` or `ImportError: No module named os` when you try to run hg.exe.
Line 27: Line 29:
 * Mercurial source release, see [Downloads]  * Mercurial source release (see [[Download]])
Line 29: Line 31:
 * The [[http://effbot.org/zone/exemaker.htm|exemaker]] launcher
Line 34: Line 35:
 * Install Python with `msiexec /i python-2.6.6.msi /qb`  * Install Python with `msiexec /i python-2.7.3.msi /qb`
Line 38: Line 39:
 * Copy the Python install from `c:\Python26` to `c:\hg\hg-python26`
 * Edit `c:\hg\hg-python26\Lib\distutils\cygwinccompiler.py` to remove all references to `-mno-cygwin` (thanks, GCC!)
 * Build Mercurial extensions in `c:\hg` with `hg-python26\python setup.py build_ext -i --compiler=mingw32`
 * Copy the `c:\hg\hg` to `c:\hg.py` and change the #! line to '#!hg-python/python.exe'
 * Unpack exemaker and copy exemaker.exe to `c:\hg\hg.exe`
 * Copy the Python install from `c:\Python27` to `c:\hg\hg-python`
 * Build Mercurial extensions in `c:\hg` with `hg-python\python setup.py build_ext -i --compiler=mingw32`
 * Build hg.exe in `c:\hg` with `hg-python\python setup.py build_hgexe -i --compiler=mingw32`
Line 45: Line 44:
Most of the test suite can be run on windows too (but only in the unreleased 2.1 which currently can be found in the ‘default’ branch). Writing tests and debugging failures might require both knowledge of the traditional unix environment and of the windows environment. Most of the test suite can now be run on windows too. Writing tests and debugging failures might however require both knowledge of the traditional unix environment and of the windows environment.
Line 47: Line 46:
The tests that can’t be run on windows will automatically be skipped, so no test failures should be seen. It is not acceptable that so many tests are skipped - please improve that. The tests that can’t be run on windows will automatically be skipped, so no test failures should be seen. The tests are run automatically by [[http://hgbuildbot.kublai.com/waterfall|the hg buildbot]].
Line 49: Line 48:
Creating a `hg-winhack` package and running the test suite requires almost the same environment. The following instructions will thus contain a lot of duplication of the instructions given above, and the instructions could perhaps be merged. (The 2.0.x “hackable” can’t be used in the default / pre-2.1 branch where testing on windows passes cleanly, so new binary modules will have to be built anyway.) Creating a `hg-winhack` package and running the test suite requires almost the same environment. The following instructions will thus contain a lot of duplication of the instructions given above, and the instructions could perhaps be merged. (The “hackable” mentioned above might not work in development branches.)
Line 52: Line 51:
 * Download an MinGW/MSYS base installer from http://sourceforge.net/projects/mingw/files/latest/download , run it and select “MSYS Basic System” component (and “C Compiler”).
 * Launch a console/terminal with: `C:\MinGW\msys\1.0\msys.bat --rxvt` and enjoy having a decent shell and run the following commands in it
 * Install mandatory extra package (dd): `mingw-get install msys-coreutils`
 * Install optional extra packages: `mingw-get install msys-rxvt msys-vim msys-wget msys-unzip msys-zip msys-openssh`
 * Install MinGW/MSYS with 'mingw-get-inst-*.exe' from http://sourceforge.net/projects/mingw/files/latest/download
 * Install some mandatory extra packages: `c:\MinGW\bin\mingw-get install msys-base msys-coreutils gcc`
 * Install some optional extra packages: `c:\MinGW\bin\mingw-get install msys-rxvt msys-vim msys-wget msys-unzip msys-zip msys-openssh`
 * Install msys-bz2-1.dll (if it's missing) with: `c:\MinGW\bin\mingw-get install msys-libbz2`
 * Launch a console/terminal with: `c:\MinGW\msys\1.0\msys.bat --rxvt` and enjoy having a decent shell
 * Make mingw gcc available: `echo "c:/mingw /mingw" >> /etc/fstab`

If you're hacking on ChangesetEvolution, you'll also need a suitable [[https://curl.haxx.se/download.html|cURL binary]]. While msys supplies wget, we prefer to use curl, as it's available on macOS by default, whereas Windows always needs an extra package (either curl or wget) installed.
Line 59: Line 62:
wget http://python.org/ftp/python/2.7.2/python-2.7.2.msi
cmd /c 'msiexec /i python-2.7.2.msi /qb' # avoid MSYS magic mangling of '/i'
hg clone http://selenic.com/hg hg-winhack # bootstrap somehow
# create build directory
hg clone http://selenic.com/hg hg-winhack # bootstrap Mercurial somehow
Line 63: Line 65:
cp -ar c:/Python27 hg-python27 # python can now be uninstalled again
sed -i 's, -mno-cygwin , ,g' hg-python27/Lib/distutils/cygwinccompiler.py
hg-python27/python setup.py build_ext -i --compiler=mingw32
sed 's,^#!/usr/bin/env python,#!hg-python27/python27.dll,g' hg > hg.py
wget http://effbot.org/media/downloads/exemaker-1.2-20041012.zip -O exemaker.zip
unzip -j exemaker.zip '*/exemaker.exe'
rm exemaker.zip
mv exemaker.exe hg.exe
# install python
wget http://python.org/ftp/python/2.7.3/python-2.7.3.msi
msiexec //i python-2.7.3.msi //qb # avoid MSYS magic mangling of '/i'
cp -ar c:/Python27 hg-python # python can and should now be uninstalled again
# build Mercurial extensions
hg-python/python setup.py build_ext -i --compiler=mingw32
# build hg.exe
hg-python/python setup.py build_hgexe -i --compiler=mingw32
# prepare localizations
hg-python/python setup.py build_mo
# zip it and ship it ... or continue running the test suite
Line 74: Line 79:
Note that this will leave you with both a `hg.exe` which can be used from windows, a `hg.py` which might be picked up if you have python installed, and a `hg` which might be picked up if you run in MSYS ... and will fail if it can't find python and the Mercurial modules. Note that this will leave you with both a `hg.exe` which can be used from windows and a `hg` which might be picked up by MSYS bash if you have python installed.
Line 80: Line 85:
PATH="`pwd`/../hg-python27:$PATH" ./run-tests.py -l --shell=sh PATH="`pwd`/../hg-python:/mingw/bin:/bin" PYTHONHOME="`pwd -W`/../hg-python" ./run-tests.py --local
}}}
PATH can be extended so other non-msys tools (such as git/svn/p4?) can be found.

=== Alternative: Building the C extensions with Microsoft compiler ===
Get and install the gratis "[[http://www.microsoft.com/en-us/download/details.aspx?id=3138|Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1]]" from microsoft.com. It contains both the x86 and x64 Microsoft C/C++ compiler. When running the web-installer, you'll only need to select the features "Windows Headers and Libraries" and "Visual C++ Compliers". Deselect everything else.

Copy `C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat` to `C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat`. When compiling Python C extensions with the compilers bundled with the Windows SDK (and not Visual Studio), you must set DISTUTILS_USE_SDK=1 in the environment, else Python distutils will give you errors about not being able to find vcvarsall.bat

To build Mercurial, in a MSYS shell do (requires Python on PATH):

{{{
make local
}}}
Or using cmd.exe:

{{{
python setup.py build_ext -i
python setup.py build_hgexe -i
}}}
Depending on what Python is used (x64 or x86), the extensions will be built for x64 or x86 accordingly.

=== Run tests involving Git ===
If you have Git installed on your Windows box, `hg-winhack` will incorrectly detect that git command is available, and will try to run Git-related tests. It will fail to do so, because it cannot run "git.cmd" from shell.

 * If you don't want to run Git tests, edit `hghave` file to `return False` instead of `return matchoutput('git --version 2>&1', r'^git version')`
 * If you prefer Git tests to be executed, find your Git installation folder, enter `cmd` folder and create `git` file (no extension) with the following contents:

{{{#!sh
#!/bin/sh
"$COMSPEC" //C git.cmd "$@"
Line 86: Line 121:
CategoryDeveloper CategoryDeveloper CategoryWindows

Hackable Mercurial for Windows

An approach to easily hack on the Mercurial source on Windows.

1. What is the Hackable package?

Compiling Mercurial is a significant barrier to testing and developing Mercurial on Windows. This package attempts to minimize that barrier by including:

  • a private copy of Python (32-bit)
  • complete Mercurial history
  • pre-compiled extensions (32-bit MinGW GCC)
  • an hg.exe wrapper to add to your path
  • in-place editable source checked out and ready to go

2. Downloading and using

The package can be found here. Simply download, unzip, and run the included hg.exe. This package will not interfere with your existing Mercurial or Python installation.

Note: The file mercurial-2.6-hackable.zip needs the following bugfix: The directory hg-python26 must be renamed to hg-python. Otherwise you will see the error message abort: failed to load Python DLL or ImportError: No module named os when you try to run hg.exe.

<!> There is usually no need to download new copies between releases, simply pull and update.

/!\ This package includes no global configuration, so if you're not already using Mercurial, you will need to configure your username and merge tools.

3. How it's built and how to build your own from scratch

Needed components:

  • Python MSI installer, versions 2.4 - 2.7
  • Mercurial source release (see Download)

  • MinGW mingw-get tool

Steps:

  • Download all the needed components
  • Install Python with msiexec /i python-2.7.3.msi /qb

  • Unpack the mingw-get tool into c:\MinGW and add c:\MinGW\bin to your path

  • Install the gcc compiler with mingw-get gcc

  • Unpack Mercurial source into c:\hg

  • Copy the Python install from c:\Python27 to c:\hg\hg-python

  • Build Mercurial extensions in c:\hg with hg-python\python setup.py build_ext -i --compiler=mingw32

  • Build hg.exe in c:\hg with hg-python\python setup.py build_hgexe -i --compiler=mingw32

4. Running the test suite under MSYS

Most of the test suite can now be run on windows too. Writing tests and debugging failures might however require both knowledge of the traditional unix environment and of the windows environment.

The tests that can’t be run on windows will automatically be skipped, so no test failures should be seen. The tests are run automatically by the hg buildbot.

Creating a hg-winhack package and running the test suite requires almost the same environment. The following instructions will thus contain a lot of duplication of the instructions given above, and the instructions could perhaps be merged. (The “hackable” mentioned above might not work in development branches.)

4.1. Install MinGW/MSYS environment

  • Install MinGW/MSYS with 'mingw-get-inst-*.exe' from http://sourceforge.net/projects/mingw/files/latest/download

  • Install some mandatory extra packages: c:\MinGW\bin\mingw-get install msys-base msys-coreutils gcc

  • Install some optional extra packages: c:\MinGW\bin\mingw-get install msys-rxvt msys-vim msys-wget msys-unzip msys-zip msys-openssh

  • Install msys-bz2-1.dll (if it's missing) with: c:\MinGW\bin\mingw-get install msys-libbz2

  • Launch a console/terminal with: c:\MinGW\msys\1.0\msys.bat --rxvt and enjoy having a decent shell

  • Make mingw gcc available: echo "c:/mingw /mingw" >> /etc/fstab

If you're hacking on ChangesetEvolution, you'll also need a suitable cURL binary. While msys supplies wget, we prefer to use curl, as it's available on macOS by default, whereas Windows always needs an extra package (either curl or wget) installed.

4.2. Build hg-winhack

# create build directory
hg clone http://selenic.com/hg hg-winhack   # bootstrap Mercurial somehow
cd hg-winhack
# install python
wget http://python.org/ftp/python/2.7.3/python-2.7.3.msi
msiexec //i python-2.7.3.msi //qb   # avoid MSYS magic mangling of '/i'
cp -ar c:/Python27 hg-python     # python can and should now be uninstalled again
# build Mercurial extensions
hg-python/python setup.py build_ext -i --compiler=mingw32
# build hg.exe
hg-python/python setup.py build_hgexe -i --compiler=mingw32
# prepare localizations
hg-python/python setup.py build_mo
# zip it and ship it ... or continue running the test suite
cd ..
zip -r hg-winhack-x.x.zip hg-winhack/

Note that this will leave you with both a hg.exe which can be used from windows and a hg which might be picked up by MSYS bash if you have python installed.

4.3. Run the test suite

cd hg-winhack/tests
export TMPDIR=c:/tmp   # to avoid path that contains ~ which in general would require escaping
PATH="`pwd`/../hg-python:/mingw/bin:/bin" PYTHONHOME="`pwd -W`/../hg-python" ./run-tests.py --local

PATH can be extended so other non-msys tools (such as git/svn/p4?) can be found.

4.4. Alternative: Building the C extensions with Microsoft compiler

Get and install the gratis "Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1" from microsoft.com. It contains both the x86 and x64 Microsoft C/C++ compiler. When running the web-installer, you'll only need to select the features "Windows Headers and Libraries" and "Visual C++ Compliers". Deselect everything else.

Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat to C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat. When compiling Python C extensions with the compilers bundled with the Windows SDK (and not Visual Studio), you must set DISTUTILS_USE_SDK=1 in the environment, else Python distutils will give you errors about not being able to find vcvarsall.bat

To build Mercurial, in a MSYS shell do (requires Python on PATH):

make local

Or using cmd.exe:

python setup.py build_ext -i
python setup.py build_hgexe -i

Depending on what Python is used (x64 or x86), the extensions will be built for x64 or x86 accordingly.

4.5. Run tests involving Git

If you have Git installed on your Windows box, hg-winhack will incorrectly detect that git command is available, and will try to run Git-related tests. It will fail to do so, because it cannot run "git.cmd" from shell.

  • If you don't want to run Git tests, edit hghave file to return False instead of return matchoutput('git --version 2>&1', r'^git version')

  • If you prefer Git tests to be executed, find your Git installation folder, enter cmd folder and create git file (no extension) with the following contents:

#!/bin/sh
"$COMSPEC" //C git.cmd "$@"

5. See also


CategoryDeveloper CategoryWindows

HackableMercurial (last edited 2018-12-05 04:34:18 by MattHarbison)