# HG changeset patch
# User Yonggang Luo <luoyonggang@gmail.com>
# Date 1302798724 -28800
# Node ID 7bf283d4c7a91e8d0ad462bd1cf7efa9651b72d7
# Parent  22f0c50c29a65f0740445ade02975b14a79211ad
Fixup Installing in Win32

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,6 +33,9 @@ def runcmd(cmd, env):
 
 
 version = ''
+HG_COMMAND = 'hg'
+if os.name == 'nt':
+	HG_COMMAND = 'hg.bat'
 
 if os.path.isdir('.hg'):
     # Execute hg out of this directory with a custom environment which
@@ -48,7 +51,7 @@ if os.path.isdir('.hg'):
         # under Windows. Otherwise, the subprocess will fail with
         # error 0xc0150004. See: http://bugs.python.org/issue3440
         env['SystemRoot'] = os.environ['SystemRoot']
-    cmd = ['hg', 'id', '-i', '-t']
+    cmd = [HG_COMMAND, 'id', '-i', '-t']
     l = runcmd(cmd, env).split()
     while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
         l.pop()
@@ -57,11 +60,11 @@ if os.path.isdir('.hg'):
         if l[0].endswith('+'): # propagate the dirty status to the tag
             version += '+'
     elif len(l) == 1: # no tag found
-        cmd = ['hg', 'parents', '--template',
+        cmd = [HG_COMMAND, 'parents', '--template',
                '{latesttag}+{latesttagdistance}-']
         version = runcmd(cmd, env) + l[0]
     if not version:
-        version = runcmd(['hg', 'parents', '--template' '{node|short}\n'],
+        version = runcmd([HG_COMMAND, 'parents', '--template' '{node|short}\n'],
                          env)
         if version:
             version = version.split()[0]