[Python-checkins] python/dist/src/Lib/plat-mac pimp.py, 1.27.4.3, 1.27.4.4

jackjansen at users.sourceforge.net jackjansen at users.sourceforge.net
Mon Jan 3 16:46:33 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11725

Modified Files:
      Tag: release23-maint
	pimp.py 
Log Message:
Backport of 1.37:
- Added an "installer" flavor, which uses the "open" command to install
  something (overridable through Install-command entry)
- Hidden status is now determined by flavor == hidden, not by
  missing Download-URL. Hidden packages behave like installer packages.
- Made some error messages a bit more understandable.

Because there's new functionality the version has been upped to 0.5.



Index: pimp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v
retrieving revision 1.27.4.3
retrieving revision 1.27.4.4
diff -u -d -r1.27.4.3 -r1.27.4.4
--- pimp.py	28 Dec 2004 21:53:15 -0000	1.27.4.3
+++ pimp.py	3 Jan 2005 15:46:30 -0000	1.27.4.4
@@ -36,12 +36,13 @@
 
 NO_EXECUTE=0
 
-PIMP_VERSION="0.4"
+PIMP_VERSION="0.5"
 
 # Flavors:
 # source: setup-based package
 # binary: tar (or other) archive created with setup.py bdist.
-DEFAULT_FLAVORORDER=['source', 'binary']
+# installer: something that can be opened
+DEFAULT_FLAVORORDER=['source', 'binary', 'installer']
 DEFAULT_DOWNLOADDIR='/tmp'
 DEFAULT_BUILDDIR='/tmp'
 DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib()
@@ -418,6 +419,10 @@
                 pkg = PimpPackage_source(self, p)
             elif flavor == 'binary':
                 pkg = PimpPackage_binary(self, p)
+            elif flavor == 'installer':
+                pkg = PimpPackage_installer(self, p)
+            elif flavor == 'hidden':
+                pkg = PimpPackage_installer(self, p)
             else:
                 pkg = PimpPackage(self, dict(p))
             self._packages.append(pkg)
@@ -543,7 +548,7 @@
             rv = rv + '-%s' % self._dict['Version']
         if self._dict.has_key('Flavor'):
             rv = rv + '-%s' % self._dict['Flavor']
-        if not self._dict.get('Download-URL'):
+        if self._dict.get('Flavor') == 'hidden':
             # Pseudo-package, show in parentheses
             rv = '(%s)' % rv
         return rv
@@ -620,11 +625,11 @@
             if status == "yes":
                 return []
             return [(None, 
-                "%s: This package cannot be installed automatically (no Download-URL field)" %
+                "Package %s cannot be installed automatically, see the description" %
                     self.fullname())]
         if self.systemwideOnly() and self._db.preferences.isUserInstall():
             return [(None,
-                "%s: This package can only be installed system-wide" %
+                "Package %s can only be installed system-wide" %
                     self.fullname())]
         if not self._dict.get('Prerequisites'):
             return []
@@ -791,7 +796,7 @@
             return "%s: Binary package cannot have Install-command" % self.fullname()
                     
         if self._dict.has_key('Pre-install-command'):
-            if _cmd(output, self._buildDirname, self._dict['Pre-install-command']):
+            if _cmd(output, '/tmp', self._dict['Pre-install-command']):
                 return "pre-install %s: running \"%s\" failed" % \
                     (self.fullname(), self._dict['Pre-install-command'])
                     
@@ -824,7 +829,7 @@
         self.afterInstall()
         
         if self._dict.has_key('Post-install-command'):
-            if _cmd(output, self._buildDirname, self._dict['Post-install-command']):
+            if _cmd(output, '/tmp', self._dict['Post-install-command']):
                 return "%s: post-install: running \"%s\" failed" % \
                     (self.fullname(), self._dict['Post-install-command'])
 
@@ -891,6 +896,37 @@
                     (self.fullname(), self._dict['Post-install-command'])
         return None
         
+class PimpPackage_installer(PimpPackage):
+
+    def unpackPackageOnly(self, output=None):
+        """We don't unpack dmg packages until installing"""
+        pass
+
+    def installPackageOnly(self, output=None):
+        """Install a single source package.
+        
+        If output is given it should be a file-like object and it
+        will receive a log of what happened."""
+                    
+        if self._dict.has_key('Post-install-command'):
+            return "%s: Installer package cannot have Post-install-command" % self.fullname()
+
+        if self._dict.has_key('Pre-install-command'):
+            if _cmd(output, '/tmp', self._dict['Pre-install-command']):
+                return "pre-install %s: running \"%s\" failed" % \
+                    (self.fullname(), self._dict['Pre-install-command'])
+                    
+        self.beforeInstall()
+
+        installcmd = self._dict.get('Install-command')
+        if installcmd:
+            if '%' in installcmd:
+                installcmd = installcmd % self.archiveFilename
+        else:
+                installcmd = 'open \"%s\"' % self.archiveFilename
+        if _cmd(output, "/tmp", installcmd):
+            return '%s: install command failed (use verbose for details)' % self.fullname()
+        return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename
     
 class PimpInstaller:
     """Installer engine: computes dependencies and installs



More information about the Python-checkins mailing list