Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing hg-git on Windows using MinGW
Here's how I installed hg-git on Windows using the MinGW compiler.
PREPARE
-------
- Install Python (http://www.activestate.com/activepython/downloads)
- Install the Python package manager, setuptools (http://pypi.python.org/pypi/setuptools)
- Install the MinGW installer (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/)
- Install the C compiler, MinGW gcc, and a utility, pexports, to help create the import library
> mingw-get install gcc
> mingw-get install mingw-utils
Create an import library for MinGW gcc (http://mercurial.selenic.com/wiki/BuildingOnWindows)
> cd c:\python26\libs
> pexports c:\windows\system32\python26.dll > python26.def
> dlltool -C -d python26.def -l libpython26.a
> nm libpython26.a # shows you the exported symbols with "I" (as import symbol)
- Configure the package manager to use the new C compiler
In C:\Python26\Lib\distutils\, create distutils.cfg with this content:
[build]
compiler=mingw32
INSTALL (http://hg-git.github.com/)
-----------------------------------
> easy_install hg-git
> cd %USERPROFILE%
> notepad .hgrc
[extensions]
hgext.bookmarks =
hggit = C:\Python26\Lib\site-packages\hg_git-0.2.6-py2.6.egg\hggit
USE (http://hg-git.github.com/)
-------------------------------
$ cd hg-git # (a Mercurial repository)
$ hg bookmark -r default master # make a bookmark of master for default, so a ref gets created
$ hg push git+ssh://git@github.com/schacon/hg-git.git
$ hg push
@urbushey

This comment has been minimized.

Copy link

urbushey commented May 27, 2012

Trying to replicate this with Python2.7, I'm unable to perform "pexports" on my python27.dll. I get:

PS C:\python27\libs> pexports c:\windows\system32\python27.dll > python27.def
stat: No such file or directory
c:\mingw\bin\pexports.exe: c:\windows\system32\python27.dll: could not load PE image

(C:\windows\system32\python27.dll exists.)

Any ideas?

@rmcmahon

This comment has been minimized.

Copy link

rmcmahon commented Feb 8, 2013

I'm also getting the same error as above with python2.7. Any help would be greatly appreciated.

@rmcmahon

This comment has been minimized.

Copy link

rmcmahon commented Feb 8, 2013

I got it to work by ignorning the section

cd c:\python26\libs
pexports c:\windows\system32\python26.dll > python26.def
dlltool -C -d python26.def -l libpython26.a
nm libpython26.a # shows you the exported symbols with "I" (as import symbol)

and just running the easy_install command again once I had the entry

[build]
compiler=mingw32

In C:\Python27\Lib\distutils\distutils.cfg which uses the gcc compiler from mingw instead.

@jimitndiaye

This comment has been minimized.

Copy link

jimitndiaye commented Mar 6, 2013

After following the instructions above on Python2.7 I get an error saying "unrecognized command line option '-mno-cygwin'" when gcc is called while installing dulwich.

@matthewvukomanovic

This comment has been minimized.

Copy link

matthewvukomanovic commented Mar 21, 2013

@jimitndiaye
I had the same problem and fixed it using the suggestion from http://stackoverflow.com/a/6035864/1462615

@Perlence

This comment has been minimized.

Copy link

Perlence commented Mar 20, 2014

To install hg-git on Python 2.7 on Windows 7 x64, I had to patch cygwinccompiler.py

--- C:\Python27\Lib\distutils\cygwinccompiler.py.orig.py
+++ C:\Python27\Lib\distutils\cygwinccompiler.py
@@ -325,7 +325,7 @@
             no_cygwin = ''

         self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
-                             compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
+                             compiler_so='gcc%s -mdll -O -Wall -D MS_WIN64' % no_cygwin,
                              compiler_cxx='g++%s -O -Wall' % no_cygwin,
                              linker_exe='gcc%s' % no_cygwin,
                              linker_so='%s%s %s %s'
@vkotovv

This comment has been minimized.

Copy link

vkotovv commented Jun 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.