From a1cef915fd689308a7d4135310679115f860201d Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Tue, 2 Nov 2010 18:47:40 -0800
Subject: [PATCH] bundled zetuptools: prefer platform-specific dists to
 platform-independent ones. refs #1233

---
 setuptools-0.6c16dev2.egg/pkg_resources.py | 26 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/setuptools-0.6c16dev2.egg/pkg_resources.py b/setuptools-0.6c16dev2.egg/pkg_resources.py
index 9828d897..00d97225 100644
--- a/setuptools-0.6c16dev2.egg/pkg_resources.py
+++ b/setuptools-0.6c16dev2.egg/pkg_resources.py
@@ -793,19 +793,33 @@ class Environment(object):
         This calls the ``find(req)`` method of the `working_set` to see if a
         suitable distribution is already active.  (This may raise
         ``VersionConflict`` if an unsuitable version of the project is already
-        active in the specified `working_set`.)  If a suitable distribution
-        isn't active, this method returns the newest distribution in the
-        environment that meets the ``Requirement`` in `req`.  If no suitable
-        distribution is found, and `installer` is supplied, then the result of
-        calling the environment's ``obtain(req, installer)`` method will be
-        returned.
+        active in the specified `working_set`.)
+
+        If a suitable distribution isn't active, this method returns the
+        newest platform-dependent distribution in the environment that meets
+        the ``Requirement`` in `req`. If no suitable platform-dependent
+        distribution is found, then the newest platform-independent
+        distribution that meets the requirement is returned. (A platform-
+        dependent distribution will typically have code compiled or
+        specialized for that platform.)
+
+        Otherwise, if `installer` is supplied, then the result of calling the
+        environment's ``obtain(req, installer)`` method will be returned.
         """
         dist = working_set.find(req)
         if dist is not None:
             return dist
+
+        # first try to find a platform-dependent dist
+        for dist in self[req.key]:
+            if dist in req and dist.platform is not None:
+                return dist
+
+        # then try any other dist
         for dist in self[req.key]:
             if dist in req:
                 return dist
+
         return self.obtain(req, installer) # try and download/install
 
     def obtain(self, requirement, installer=None):
-- 
2.45.2