[PATCH 1 of 1] setup.py: fixing version info for Windows hg.exe (py2exe)

Adrian Buehlmann adrian at cadifra.com
Sun Feb 7 16:27:46 CST 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1265580478 -3600
# Node ID 1b26e381233a0ebf253aae0e0316c2ca23e9cfe2
# Parent  1ddb0ae26a55989b72bed9239ef641000931ed7d
setup.py: fixing version info for Windows hg.exe (py2exe)

Fixes

  warning: py2exe: Version Info will not be included:
    could not parse version number ...

which was seen when doing nightly builds. hg.exe files
of nightly builds did not have any version info resoure,
which may cause problems with installers.

Also setting a copyright string for the version resource
(was missing).

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -37,7 +37,6 @@ from distutils.command.build_py import b
 from distutils.spawn import spawn, find_executable
 from distutils.ccompiler import new_compiler
 
-extra = {}
 scripts = ['hg']
 if os.name == 'nt':
     scripts.append('contrib/win32/hg.bat')
@@ -77,6 +76,7 @@ def hasfunction(cc, funcname):
 # py2exe needs to be installed to work
 try:
     import py2exe
+    py2exeloaded = True
 
     # Help py2exe to find win32com.shell
     try:
@@ -92,9 +92,8 @@ try:
     except ImportError:
         pass
 
-    extra['console'] = ['hg']
-
 except ImportError:
+    py2exeloaded = False
     pass
 
 def runcmd(cmd, env):
@@ -266,9 +265,22 @@ for root in ('templates',):
             packagedata['mercurial'].append(f)
 
 datafiles = []
+setupversion = version
+extra = {}
+
+if py2exeloaded:
+    extra['console'] = [
+        {'script':'hg',
+         'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
+         'product_version':version}]
+
+if os.name == 'nt':
+    # Windows binary file versions for exe/dll files must have the
+    # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
+    setupversion = version.split('+', 1)[0]
 
 setup(name='mercurial',
-      version=version,
+      version=setupversion,
       author='Matt Mackall',
       author_email='mpm at selenic.com',
       url='http://mercurial.selenic.com/',


More information about the Mercurial-devel mailing list