--- pywin32-212/setup.py	Sun Jul 27 22:53:00 2008
+++ pywin32-212.new/setup.py	Thu Jun 18 18:34:58 2009
@@ -1,4 +1,4 @@
-build_id="212" # may optionally include a ".{patchno}" suffix.
+build_id="2.1.2" # may optionally include a ".{patchno}" suffix.
 # Putting buildno at the top prevents automatic __doc__ assignment, and
 # I *want* the build number at the top :)
 __doc__="""This is a distutils setup-script for the pywin32 extensions
@@ -1123,10 +1123,12 @@
             filename = os.path.join(os.path.dirname(this_file), "pywin32_postinstall.py")
             if not os.path.isfile(filename):
                 raise RuntimeError, "Can't find '%s'" % (filename,)
-            print "Executing post install script..."
-            os.spawnl(os.P_NOWAIT, sys.executable,
-                      sys.executable, filename,
-                      "-quiet", "-wait", str(os.getpid()), "-install")
+	    
+	    if 'bdist_msi' not in sys.argv:
+		print "Executing post install script..."
+		os.spawnl(os.P_NOWAIT, sys.executable,
+		          sys.executable, filename,
+			  "-quiet", "-wait", str(os.getpid()), "-install")
 
 # As per get_source_files, we need special handling so .mc file is
 # processed first.  It appears there was an intention to fix distutils
@@ -1811,6 +1813,23 @@
              'install_data': my_install_data,
            }
     
+if 'bdist_msi' in sys.argv:
+  scripts = ["pywin32_msi_postinstall.py"]
+  msi_postinstall = open(scripts[0], 'wb')
+  fobj = open("pywin32_postinstall.py")
+  while True:
+      input = fobj.readline()
+      if input in ('', "if __name__=='__main__':\n"):
+	  break
+
+      msi_postinstall.write(input)
+
+  msi_postinstall.write("if __name__=='__main__': install()")
+  fobj.close()
+  msi_postinstall.close()
+else:
+  scripts = ["pywin32_postinstall.py"],
+
 dist = setup(name="pywin32",
       version=str(build_id),
       description="Python for Window Extensions",
@@ -1829,11 +1848,11 @@
                      "user_access_control": "auto",
                     },
                  "bdist_msi":
-                    {"install_script": "pywin32_postinstall.py",
+                    {"install_script": scripts[0],
                     },
                 },
 
-      scripts = ["pywin32_postinstall.py"],
+      scripts = scripts,
 
       ext_modules = ext_modules,
 
