[Python-checkins] python/nondist/sandbox/setuptools EasyInstall.txt, 1.45, 1.46 api_tests.txt, 1.1, 1.2 pkg_resources.py, 1.48, 1.49

pje@users.sourceforge.net pje at users.sourceforge.net
Thu Jul 21 03:11:34 CEST 2005


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

Modified Files:
	EasyInstall.txt api_tests.txt pkg_resources.py 
Log Message:
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.)


Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- EasyInstall.txt	18 Jul 2005 02:06:15 -0000	1.45
+++ EasyInstall.txt	21 Jul 2005 01:11:31 -0000	1.46
@@ -619,6 +619,17 @@
    rate don't expect it to work with all packages.
 
 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.)
+
+ * Fixed installing extra ``.pyc`` or ``.pyo`` files for scripts with ``.py``
+   extensions.
+
  * Added ``--site-dirs`` option to allow adding custom "site" directories.
    Made ``easy-install.pth`` work in platform-specific alternate site
    directories (e.g. ``~/Library/Python/2.x/site-packages``).

Index: api_tests.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/api_tests.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- api_tests.txt	18 Jul 2005 01:39:45 -0000	1.1
+++ api_tests.txt	21 Jul 2005 01:11:31 -0000	1.2
@@ -245,3 +245,38 @@
     >>> ws.add(Distribution(project_name="JustATest", version="0.99"))
     Added JustATest 0.99
 
+
+Platform Compatibility Rules
+----------------------------
+
+On the Mac, there are potential compatibility issues for modules compiled
+on newer versions of Mac OS X than what the user is running. Additionally,
+Mac OS X will soon have two platforms to contend with: Intel and PowerPC.
+
+Basic equality works as on other platforms::
+
+    >>> from pkg_resources import compatible_platforms as cp
+    >>> reqd = 'macosx-10.4.2-Power_Macintosh'
+    >>> cp(reqd, reqd)
+    True
+    >>> cp("win32", reqd)
+    False
+
+Distributions made on other machine types are not compatible::
+
+    >>> cp("macosx-10.4.2-Intel", reqd)
+    False
+
+Distributions made on earlier versions of the OS are compatible, as
+long as they are from the same top-level version. The patchlevel version
+number does not matter::
+
+    >>> cp("macosx-10.4.5-Power_Macintosh", reqd)
+    True
+    >>> cp("macosx-10.3.5-Power_Macintosh", reqd)
+    True
+    >>> cp("macosx-10.5.5-Power_Macintosh", reqd)
+    False
+    >>> cp("macosx-9.5.5-Power_Macintosh", reqd)
+    False
+

Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- pkg_resources.py	18 Jul 2005 02:28:14 -0000	1.48
+++ pkg_resources.py	21 Jul 2005 01:11:31 -0000	1.49
@@ -80,15 +80,47 @@
 
 
 
+def _macosx_vers(_cache=[]):
+    if not _cache:
+        info = os.popen('/usr/bin/sw_vers').read().splitlines()
+        for line in info:
+            key, value = line.split(None, 1)
+            if key == 'ProductVersion:':
+                _cache.append(value.strip().split("."))
+                break
+        else:
+            raise ValueError, "What?!"
+    return _cache[0]
+
+
 def get_platform():
     """Return this platform's string for platform-specific distributions
 
     XXX Currently this is the same as ``distutils.util.get_platform()``, but it
     needs some hacks for Linux and Mac OS X.
     """
+    if sys.platform == "darwin":
+        try:
+            version = _macosx_vers()
+            machine = os.uname()[4].replace(" ", "_")
+            return "macosx-%d.%d.%d-%s" % (int(version[0]), int(version[1]),
+                int(version[2]), 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+)\.(\d+)-(.*)")
+# XXX darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
+
+
+
+
+
+
 def compatible_platforms(provided,required):
     """Can code for the `provided` platform run on the `required` platform?
 
@@ -99,9 +131,37 @@
     if provided is None or required is None or provided==required:
         return True     # easy case
 
-    # XXX all the tricky cases go here
+    # Mac OS X special cases
+    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
+        
+        # are they the same major version and machine type?
+        if provMac.group(1) != reqMac.group(1) or \
+            provMac.group(4) != reqMac.group(4):
+            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        
     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
@@ -113,14 +173,6 @@
 run_main = run_script   # backward compatibility
 
 
-
-
-
-
-
-
-
-
 class IMetadataProvider:
 
     def has_metadata(name):
@@ -151,17 +203,6 @@
 
 
 
-
-
-
-
-
-
-
-
-
-
-
 class IResourceProvider(IMetadataProvider):
     """An object that provides access to package resources"""
 



More information about the Python-checkins mailing list