[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/easy_install. Added an api to change the default policy for unzipping zip-safe eggs.

Jim Fulton jim at zope.com
Fri Jul 18 16:51:38 EDT 2008


Log message for revision 88549:
  Added an api to change the default policy for unzipping zip-safe eggs.
  

Changed:
  U   zc.buildout/trunk/src/zc/buildout/easy_install.py
  U   zc.buildout/trunk/src/zc/buildout/easy_install.txt

-=-
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py	2008-07-18 20:51:12 UTC (rev 88548)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py	2008-07-18 20:51:27 UTC (rev 88549)
@@ -125,13 +125,14 @@
     _prefer_final = True
     _use_dependency_links = True
     _allow_picked_versions = True
+    _always_unzip = False
     
     def __init__(self,
                  dest=None,
                  links=(),
                  index=None,
                  executable=sys.executable,
-                 always_unzip=False,
+                 always_unzip=None,
                  path=None,
                  newest=True,
                  versions=None,
@@ -156,7 +157,8 @@
 
         self._index_url = index
         self._executable = executable
-        self._always_unzip = always_unzip
+        if always_unzip is not None:
+            self._always_unzip = always_unzip
         path = (path and path[:] or []) + buildout_and_setuptools_path
         if dest is not None and dest not in path:
             path.insert(0, dest)
@@ -740,9 +742,15 @@
         Installer._allow_picked_versions = bool(setting)
     return old
 
+def always_unzip(setting=None):
+    old = Installer._always_unzip
+    if setting is not None:
+        Installer._always_unzip = bool(setting)
+    return old
+
 def install(specs, dest,
             links=(), index=None,
-            executable=sys.executable, always_unzip=False,
+            executable=sys.executable, always_unzip=None,
             path=None, working_set=None, newest=True, versions=None,
             use_dependency_links=None, allow_hosts=('*',)):
     installer = Installer(dest, links, index, executable, always_unzip, path,

Modified: zc.buildout/trunk/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.txt	2008-07-18 20:51:12 UTC (rev 88548)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.txt	2008-07-18 20:51:27 UTC (rev 88549)
@@ -224,6 +224,45 @@
     >>> dest = tmpdir('sample-install')
     >>> ws = zc.buildout.easy_install.install(
     ...     ['demo'], dest, links=[link_server], index=link_server+'index/',
+    ...     always_unzip=False)
+
+    >>> ls(dest)
+    -  demo-0.3-py2.4.egg
+    -  demoneeded-1.1-py2.4.egg
+
+We can also set a default by calling the always_unzip function:
+
+    >>> zc.buildout.easy_install.always_unzip(True)
+    False
+
+The old default is returned:
+
+    >>> rmdir(dest)
+    >>> dest = tmpdir('sample-install')
+    >>> ws = zc.buildout.easy_install.install(
+    ...     ['demo'], dest, links=[link_server], index=link_server+'index/')
+
+    >>> ls(dest)
+    d  demo-0.3-py2.4.egg
+    d  demoneeded-1.1-py2.4.egg
+
+
+    >>> zc.buildout.easy_install.always_unzip(False)
+    True
+
+    >>> rmdir(dest)
+    >>> dest = tmpdir('sample-install')
+    >>> ws = zc.buildout.easy_install.install(
+    ...     ['demo'], dest, links=[link_server], index=link_server+'index/')
+
+    >>> ls(dest)
+    -  demo-0.3-py2.4.egg
+    -  demoneeded-1.1-py2.4.egg
+
+    >>> rmdir(dest)
+    >>> dest = tmpdir('sample-install')
+    >>> ws = zc.buildout.easy_install.install(
+    ...     ['demo'], dest, links=[link_server], index=link_server+'index/',
     ...     always_unzip=True)
 
     >>> ls(dest)



More information about the Checkins mailing list