[Checkins] SVN: zc.buildout/branches/alex-buildout/src/zc/buildout/ Added -b and -B options to buildout.py.

Alexander Heavner alex at zope.com
Thu Mar 15 15:47:21 EDT 2007


Log message for revision 73206:
  Added -b and -B options to buildout.py.
  Began work on implementing -b and -B options in easy_install.py.
  

Changed:
  U   zc.buildout/branches/alex-buildout/src/zc/buildout/buildout.py
  U   zc.buildout/branches/alex-buildout/src/zc/buildout/easy_install.py

-=-
Modified: zc.buildout/branches/alex-buildout/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/alex-buildout/src/zc/buildout/buildout.py	2007-03-15 19:42:27 UTC (rev 73205)
+++ zc.buildout/branches/alex-buildout/src/zc/buildout/buildout.py	2007-03-15 19:47:20 UTC (rev 73206)
@@ -1201,6 +1201,10 @@
                     options.append(('buildout', 'newest', 'false'))
                 elif op[0] == 'D':
                     debug = True
+                elif op[0] == 'B':
+                    zc.buildout.easy_install.set_download_type(False)
+                elif op[0] == 'b':
+                    zc.buildout.easy_install.set_download_type(True)
                 else:
                     _help()
                 op = op[1:]

Modified: zc.buildout/branches/alex-buildout/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/alex-buildout/src/zc/buildout/easy_install.py	2007-03-15 19:42:27 UTC (rev 73205)
+++ zc.buildout/branches/alex-buildout/src/zc/buildout/easy_install.py	2007-03-15 19:47:20 UTC (rev 73206)
@@ -28,6 +28,8 @@
 import setuptools.archive_util
 import zc.buildout
 
+download_binary_distributions = True
+
 default_index_url = os.environ.get('buildout-testing-index-url')
 
 logger = logging.getLogger('zc.buildout.easy_install')
@@ -46,6 +48,24 @@
         pkg_resources.Requirement.parse('zc.buildout')).location,
     ]
 
+def set_download_type(value):
+    global download_binary_distributions
+    
+    if value in [True, False]:
+        # Make sure that if True or False has been specified using 1 or 0 to
+        # convert it to the constant
+        if value == 1:
+            value = True
+        else:
+            value = False
+        
+        download_binary_distributions = value
+    else:
+        raise zc.buildout.UserError(
+                        "Only True and False are valid"
+                        )
+    
+
 class IncompatibleVersionError(zc.buildout.UserError):
     """A specified version is incompatible with a given requirement.
     """
@@ -184,7 +204,7 @@
                 lastv = v
 
         best_we_have = dists[0] # Because dists are sorted from best to worst
-
+                
         # Check if we have the upper limit
         if maxv is not None and best_we_have.version == maxv:
             logger.debug('We have the best distribution that satisfies\n%s',
@@ -414,7 +434,21 @@
 
         for requirement in requirements:
             dist = self._get_dist(requirement, ws, self._always_unzip)
-            ws.add(dist)
+            # Only add the distribution to the working set if it is platform
+            # independent
+            if dist.platform is None or not download_binary_distributions :
+                ws.add(dist)
+            else:
+                distList = self._env.__getitem__(requirement)
+               
+                # env.__getitem__ returns a list sorted by version number
+                # therefore the first version found that is platform independent
+                # is the one we want
+                for adist in distList:
+                    if adist is none:
+                        dist = adist
+                        break
+               
             self._maybe_add_setuptools(ws, dist)
 
         # OK, we have the requested distributions and they're in the working
@@ -433,8 +467,8 @@
                 requirement = self._constrain(requirement)
                 if dest:
                     logger.debug('Getting required %s', requirement)
-                dist = self._get_dist(requirement, ws, self._always_unzip)
                 ws.add(dist)
+                            
                 self._maybe_add_setuptools(ws, dist)
             else:
                 break



More information about the Checkins mailing list