[Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.46, 1.47

theller at users.sourceforge.net theller at users.sourceforge.net
Fri Feb 20 09:43:15 EST 2004


Update of /cvsroot/python/python/dist/src/Lib/distutils/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28174

Modified Files:
	bdist_wininst.py 
Log Message:
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.

install.c: support for a 'pre-install-script', run before anything has
been installed. Provides a 'message_box' module function for use by
either the pre-install or post-install scripts.

bdist_wininst.py: support for pre-install script. Typo (build->built),
fixes so that --target-version can still work, even when the
distribution has extension modules - in this case, we insist on
--skip-build, as we still can't actually build other versions.


Index: bdist_wininst.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** bdist_wininst.py	12 Jun 2003 17:23:58 -0000	1.46
--- bdist_wininst.py	20 Feb 2004 14:43:03 -0000	1.47
***************
*** 44,47 ****
--- 44,51 ----
                       "basename of installation script to be run after"
                       "installation or before deinstallation"),
+                     ('pre-install-script=', None,
+                      "Fully qualified filename of a script to be run before "
+                      "any files are installed.  This script need not be in the "
+                      "distribution"),
                     ]
  
***************
*** 60,63 ****
--- 64,68 ----
          self.skip_build = 0
          self.install_script = None
+         self.pre_install_script = None
  
      # initialize_options()
***************
*** 70,78 ****
          if not self.target_version:
              self.target_version = ""
!         if self.distribution.has_ext_modules():
              short_version = get_python_version()
              if self.target_version and self.target_version != short_version:
                  raise DistutilsOptionError, \
!                       "target version can only be" + short_version
              self.target_version = short_version
  
--- 75,84 ----
          if not self.target_version:
              self.target_version = ""
!         if not self.skip_build and self.distribution.has_ext_modules():
              short_version = get_python_version()
              if self.target_version and self.target_version != short_version:
                  raise DistutilsOptionError, \
!                       "target version can only be %s, or the '--skip_build'" \
!                       " option must be specified" % (short_version,)
              self.target_version = short_version
  
***************
*** 110,113 ****
--- 116,134 ----
          install_lib.compile = 0
          install_lib.optimize = 0
+         
+         # If we are building an installer for a Python version other
+         # than the one we are currently running, then we need to ensure
+         # our build_lib reflects the other Python version rather than ours.
+         # Note that for target_version!=sys.version, we must have skipped the
+         # build step, so there is no issue with enforcing the build of this
+         # version.
+         target_version = self.target_version
+         if not target_version:
+             assert self.skip_build, "Should have already checked this"
+             target_version = sys.version[0:3]
+         plat_specifier = ".%s-%s" % (get_platform(), target_version)
+         build = self.get_finalized_command('build')
+         build.build_lib = os.path.join(build.build_base,
+                                        'lib' + plat_specifier)
  
          # Use a custom scheme for the zip-file, because we have to decide
***************
*** 188,192 ****
          import time
          import distutils
!         build_info = "Build %s with distutils-%s" % \
                       (time.ctime(time.time()), distutils.__version__)
          lines.append("build_info=%s" % build_info)
--- 209,213 ----
          import time
          import distutils
!         build_info = "Built %s with distutils-%s" % \
                       (time.ctime(time.time()), distutils.__version__)
          lines.append("build_info=%s" % build_info)
***************
*** 224,227 ****
--- 245,253 ----
              file.write(bitmapdata)
  
+         # Append the pre-install script
+         cfgdata = cfgdata + "\0"
+         if self.pre_install_script:
+             script_data = open(self.pre_install_script, "r").read()
+             cfgdata = cfgdata + script_data + "\n\0"
          file.write(cfgdata)
          header = struct.pack("<iii",




More information about the Python-checkins mailing list