Jason R. Coombs committed 70b6099

Fixed ImportError on Command class
Ported use of StrictVersion to NormalizedVersions (introduces MSIVersion).

Comments (0)

Files changed (1)


 import sys, os
 from sysconfig import get_python_version
-from distutils2.core import Command
-from distutils2.version import StrictVersion
+from distutils2.command.cmd import Command
+from distutils2.version import NormalizedVersion
 from distutils2.errors import DistutilsOptionError
 from distutils2 import log
 from distutils2.util import get_platform
 from msilib import schema, sequence, text
 from msilib import Directory, Feature, Dialog, add_data
+class MSIVersion(NormalizedVersion):
+    """
+    MSI ProductVersion must be strictly numeric.
+    MSIVersion disallows prerelease and postrelease versions.
+    """
+    def __init__(self, *args, **kwargs):
+        super(MSIVersion, self).__init__(*args, **kwargs)
+        if not self.is_final:
+            raise ValueError("ProductVersion must be strictly numeric")
 class PyDialog(Dialog):
     """Dialog class with a fixed layout: controls at the top, then a ruler,
     then a list of buttons: back, next, cancel. Optionally a bitmap at the
             author = metadata.maintainer
         if not author:
             author = "UNKNOWN"
-        version = metadata.get_version()
-        # ProductVersion must be strictly numeric
-        # XXX need to deal with prerelease versions
-        sversion = "%d.%d.%d" % StrictVersion(version).version
+        version = MSIVersion(metadata.get_version())
         # Prefix ProductName with Python x.y, so that
         # it sorts together with the other Python packages
         # in Add-Remove-Programs (APR)
             product_name = "Python %s" % (fullname)
         self.db = msilib.init_database(installer_name, schema,
                 product_name, msilib.gen_uuid(),
-                sversion, author)
+                str(version), author)
         msilib.add_tables(self.db, sequence)
         props = [('DistVersion', version)]
         email = metadata.author_email or metadata.maintainer_email