[Python-checkins] python/nondist/sandbox/setuptools EasyInstall.txt, 1.46, 1.47 api_tests.txt, 1.3, 1.4 pkg_resources.py, 1.50, 1.51

pje@users.sourceforge.net pje at users.sourceforge.net
Thu Jul 21 18:11:36 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23992

Modified Files:
	EasyInstall.txt api_tests.txt pkg_resources.py 
Log Message:
Improved backward compatibility of Mac OS platform string changes, thanks
to more help from Kevin Dangoor.


Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- EasyInstall.txt	21 Jul 2005 01:11:31 -0000	1.46
+++ EasyInstall.txt	21 Jul 2005 16:11:33 -0000	1.47
@@ -620,12 +620,11 @@
 
 0.6a1
  * Added support for handling MacOS platform information in ``.egg`` filenames,
-   based on a contribution by Kevin Dangoor.  (NOTE: this may make eggs
-   compiled for OS X with older versions of setuptools unusable!  If you have
-   eggs whose file/directory names end with ``-darwin-*.egg``, you will
-   probably need to rename them to ``-macosx-*.egg``, substituting your current
-   Mac OS version for the darwin kernel version in the version number.  Or, you
-   can just delete and reinstall the problematic eggs.)
+   based on a contribution by Kevin Dangoor.  You may wish to delete and
+   reinstall any eggs whose filename includes "darwin" and "Power_Macintosh",
+   because the format for this platform information has changed so that minor
+   OS X upgrades (such as 10.4.1 to 10.4.2) do not cause eggs built with a
+   previous OS version to become obsolete.
 
  * Fixed installing extra ``.pyc`` or ``.pyo`` files for scripts with ``.py``
    extensions.

Index: api_tests.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/api_tests.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- api_tests.txt	21 Jul 2005 04:50:50 -0000	1.3
+++ api_tests.txt	21 Jul 2005 16:11:34 -0000	1.4
@@ -280,3 +280,13 @@
     >>> cp("macosx-9.5-ppc", reqd)
     False
 
+Backwards compatibility for packages made via earlier versions of 
+setuptools is provided as well::
+
+    >>> cp("darwin-8.2.0-Power_Macintosh", reqd)
+    True
+    >>> cp("darwin-7.2.0-Power_Macintosh", reqd)
+    True
+    >>> cp("darwin-8.2.0-Power_Macintosh", "macosx-10.3-ppc")
+    False
+

Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- pkg_resources.py	21 Jul 2005 04:50:50 -0000	1.50
+++ pkg_resources.py	21 Jul 2005 16:11:34 -0000	1.51
@@ -92,6 +92,8 @@
             raise ValueError, "What?!"
     return _cache[0]
 
+def _macosx_arch(machine):
+    return {'PowerPC':'ppc', 'Power_Macintosh':'ppc'}.get(machine,machine)
 
 def get_platform():
     """Return this platform's string for platform-specific distributions
@@ -103,21 +105,19 @@
         try:
             version = _macosx_vers()
             machine = os.uname()[4].replace(" ", "_")
-            machine = {
-                'PowerPC':'ppc', 'Power_Macintosh':'ppc'
-            }.get(machine,machine)
             return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]),
-                machine)
+                _macosx_arch(machine))
         except ValueError:
             # if someone is running a non-Mac darwin system, this will fall
             # through to the default implementation
             pass
-            
+
     from distutils.util import get_platform
     return get_platform()
 
 macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
-# XXX darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
+darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
+
 
 
 
@@ -135,33 +135,44 @@
     reqMac = macosVersionString.match(required)
     if reqMac:
         provMac = macosVersionString.match(provided)
-        
+
         # is this a Mac package?
         if not provMac:
-            # XXX backward compatibility should go here!            
-            return False
-        
+            # this is backwards compatibility for packages built before
+            # setuptools 0.6. All packages built after this point will
+            # use the new macosx designation.
+            provDarwin = darwinVersionString.match(provided)
+            if provDarwin:
+                dversion = int(provDarwin.group(1))
+                macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2))
+                if dversion == 7 and macosversion >= "10.3" or \
+                    dversion == 8 and macosversion >= "10.4":
+
+                    #import warnings
+                    #warnings.warn("Mac eggs should be rebuilt to "
+                    #    "use the macosx designation instead of darwin.",
+                    #    category=DeprecationWarning)
+                    return True
+
+            return False    # egg isn't macosx or legacy darwin
+
         # are they the same major version and machine type?
         if provMac.group(1) != reqMac.group(1) or \
             provMac.group(3) != reqMac.group(3):
             return False
-        
+
+
         # is the required OS major update >= the provided one?
         if int(provMac.group(2)) > int(reqMac.group(2)):
             return False
-        
+
         return True
 
-    # XXX Linux and other platforms' special cases should go here        
+    # XXX Linux and other platforms' special cases should go here
     return False
 
 
 
-
-
-
-
-
 def run_script(dist_spec, script_name):
     """Locate distribution `dist_spec` and run its `script_name` script"""
     ns = sys._getframe(1).f_globals
@@ -173,6 +184,25 @@
 run_main = run_script   # backward compatibility
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 class IMetadataProvider:
 
     def has_metadata(name):
@@ -203,6 +233,17 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
 class IResourceProvider(IMetadataProvider):
     """An object that provides access to package resources"""
 



More information about the Python-checkins mailing list