]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't uninstall common files if there is more than one wxPython installed
authorRobin Dunn <robin@alldunn.com>
Sun, 24 Oct 2004 00:17:12 +0000 (00:17 +0000)
committerRobin Dunn <robin@alldunn.com>
Sun, 24 Oct 2004 00:17:12 +0000 (00:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/distrib/mac/uninstall_wxPython.py

index 80373c232e8aeb16c08aca5a1c5a8d2ab6174872..9900d930ba8113fa83b452765dbea5666e1f93d5 100755 (executable)
@@ -13,19 +13,31 @@ yourself.
 """
 
 import sys, os, glob
+from fnmatch import fnmatchcase
 import cPickle, urllib
 
 RCPTDIR = "/Library/Receipts"
 RSRCDIR = "Contents/Resources"
 
-# only clean up dirs that have one of these as a prefix.  We do this
-# because the file list returned from lsbom will include /, /usr,
-# /usr/local, etc.
+# Only completly clean out dirs that have one of these as a prefix.
+# We do this because the file list returned from lsbom will include /,
+# /usr, /usr/local, etc.
 PREFIXES = [ '/Library/Python/2.3/',
              '/Library/Python/2.4/',
+             '/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-pacakges/',
+             '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-pacakges/',
              '/usr/local/lib/',
              ]
 
+# The files that match one of the items in this list will only be
+# removed if the last installation of wxPython on the system is being
+# uninstalled.
+COMMON_FILES = [ '/usr/local/bin/*',
+                 'wx.pth',
+                 'wxversion.py',
+                 ]
+    
+
 
 class AccessError(Exception):
     pass
@@ -87,10 +99,18 @@ class InstalledReceipt(object):
             handleDir(dirpath)
 
 
+    def testCommon(self, name):
+        for cmn in COMMON_FILES:
+            if fnmatchcase(name, cmn) or fnmatchcase(os.path.basename(name), cmn):
+                return True
+        return False
+
 
     def showFiles(self):
         def show(name):
             if os.path.exists(name):
+                if not self.lastInstall and self.testCommon(name):
+                    return
                 print "Will remove:", name
         self.walkFiles(show, show)
 
@@ -98,6 +118,8 @@ class InstalledReceipt(object):
     def testUninstallAccess(self):
         def testFile(name):
             if os.path.exists(name):
+                if not self.lastInstall and self.testCommon(name):
+                    return
                 if not os.access(name, os.W_OK):
                     raise AccessError(name)
         self.walkFiles(testFile, testFile)
@@ -106,13 +128,15 @@ class InstalledReceipt(object):
     def doUninstall(self):
         def removeFile(name):
             if os.path.exists(name):
+                if not self.lastInstall and self.testCommon(name):
+                    return
                 print "Removing:", name
                 os.unlink(name)
         def removeDir(name):
             print "Removing:", name
             if os.path.exists(name):
                 hasFiles = os.listdir(name)
-                if hasFiles:  # perhaps some left over symlinks, or .pyc files
+                if hasFiles:  # perhaps some stale symlinks, or .pyc files
                     for file in hasFiles:
                         os.unlink(os.path.join(name, file))
                 os.rmdir(name)
@@ -167,6 +191,7 @@ def main():
     if ans in ['Q', 'q']:
         sys.exit()
     inst = installed[int(ans) - 1]
+    inst.lastInstall = len(installed) == 1
 
     while True:
         print