[Checkins] SVN: zc.buildout/branches/help-api/ Added the `dependent-scripts` option. When set to `true`, scripts will

Godefroid Chapelle gotcha at bubblenet.be
Sun Mar 29 17:26:45 EDT 2009


Log message for revision 98553:
  Added the `dependent-scripts` option.  When set to `true`, scripts will
  be generated for all required eggs in addition to the eggs named
  specifically.
  
  The implementation is short and simple, but testing it required
  changes in a lot of places.

Changed:
  U   zc.buildout/branches/help-api/src/zc/buildout/downloadcache.txt
  U   zc.buildout/branches/help-api/src/zc/buildout/easy_install.txt
  U   zc.buildout/branches/help-api/src/zc/buildout/tests.py
  U   zc.buildout/branches/help-api/zc.recipe.egg_/CHANGES.txt
  U   zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/README.txt
  U   zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/egg.py

-=-
Modified: zc.buildout/branches/help-api/src/zc/buildout/downloadcache.txt
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/downloadcache.txt	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/src/zc/buildout/downloadcache.txt	2009-03-29 21:26:45 UTC (rev 98553)
@@ -33,6 +33,7 @@
 
     >>> print get(link_server),
     <html><body>
+    <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
     <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
     <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>

Modified: zc.buildout/branches/help-api/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/easy_install.txt	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/src/zc/buildout/easy_install.txt	2009-03-29 21:26:45 UTC (rev 98553)
@@ -96,6 +96,7 @@
 
     >>> print get(link_server),
     <html><body>
+    <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
     <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
     <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
@@ -896,6 +897,7 @@
     >>> update_extdemo()
     >>> print get(link_server),
     <html><body>
+    <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
     <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
     <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>

Modified: zc.buildout/branches/help-api/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/tests.py	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/src/zc/buildout/tests.py	2009-03-29 21:26:45 UTC (rev 98553)
@@ -3038,6 +3038,18 @@
                 " zip_safe=True, version='0.%s%s')\n" % (i, c1)
                 )
             zc.buildout.testing.bdist_egg(tmp, executable, dest)
+
+        write(tmp, 'eggrecipebigdemo.py', 'import eggrecipedemo')
+        write(
+            tmp, 'setup.py',
+            "from setuptools import setup\n"
+            "setup(name='bigdemo', "
+            " install_requires = 'demo',"
+            " py_modules=['eggrecipebigdemo'], "
+            " zip_safe=True, version='0.1')\n"
+            )
+        zc.buildout.testing.bdist_egg(tmp, executable, dest)
+
     finally:
         shutil.rmtree(tmp)
 

Modified: zc.buildout/branches/help-api/zc.recipe.egg_/CHANGES.txt
===================================================================
--- zc.buildout/branches/help-api/zc.recipe.egg_/CHANGES.txt	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/zc.recipe.egg_/CHANGES.txt	2009-03-29 21:26:45 UTC (rev 98553)
@@ -8,6 +8,16 @@
 Change History
 **************
 
+1.1.1 (unreleased)
+==================
+
+- Added the `dependent-scripts` option.  When set to `true`, scripts will
+  be generated for all required eggs in addition to the eggs named
+  specifically.  This idea came from two forks of this recipe,
+  `repoze.recipe.egg` and `pylons_sandbox`, but the option name is
+  spelled with a dash instead of underscore and it defaults to `false`.
+
+
 1.1.0 (2008-07-19)
 ==================
 

Modified: zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-03-29 21:26:45 UTC (rev 98553)
@@ -33,6 +33,7 @@
 
     >>> print get(link_server),
     <html><body>
+    <a href="bigdemo-0.1-py2.3.egg">bigdemo-0.1-py2.3.egg</a><br>
     <a href="demo-0.1-py2.3.egg">demo-0.1-py2.3.egg</a><br>
     <a href="demo-0.2-py2.3.egg">demo-0.2-py2.3.egg</a><br>
     <a href="demo-0.3-py2.3.egg">demo-0.3-py2.3.egg</a><br>
@@ -129,7 +130,7 @@
    name=module:attrs
 
    where name is a script name, module is a dotted name resolving to a
-   module name, and a attrs is a dotted name resolving to a callable
+   module name, and attrs is a dotted name resolving to a callable
    object within a module.
 
    This option is useful when working with distributions that don't
@@ -146,6 +147,10 @@
    disabled.  If the option isn't given at all, then all scripts
    defined by the named eggs will be generated.
 
+dependent-scripts
+   If set to the string "true", scripts will be generated for all
+   required eggs in addition to the eggs specifically named.
+
 interpreter
    The name of a script to generate that allows access to a Python
    interpreter that has the path set based on the eggs installed.
@@ -482,6 +487,31 @@
     if __name__ == '__main__':
         foo.bar.a.b.c()
 
+Generating all scripts
+----------------------
+
+The `bigdemo` package doesn't have any scripts, but it requires the `demo`
+package, which does have a script.  Specify `dependent-scripts = true` to
+generate all scripts in required packages:
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = bigdemo
+    ...
+    ... [bigdemo]
+    ... recipe = zc.recipe.egg
+    ... find-links = %(server)s
+    ... index = %(server)s/index
+    ... dependent-scripts = true
+    ... """ % dict(server=link_server))
+    >>> print system(buildout+' -N'),
+    Uninstalling demo.
+    Installing bigdemo.
+    Getting distribution for 'bigdemo'.
+    Got bigdemo 0.1.
+    Generated script '/sample-buildout/bin/demo'.
+
 Offline mode
 ------------
 
@@ -501,6 +531,6 @@
     ... """ % dict(server=link_server))
 
     >>> print system(buildout),
-    Uninstalling demo.
+    Uninstalling bigdemo.
     Installing demo.
     Generated script '/sample-buildout/bin/foo'.

Modified: zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/egg.py
===================================================================
--- zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-03-29 21:26:37 UTC (rev 98552)
+++ zc.buildout/branches/help-api/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-03-29 21:26:45 UTC (rev 98553)
@@ -76,12 +76,8 @@
                 )
         else:
             kw = {}
-            always_unzip = options.get('unzip')
-            if always_unzip is not None:
-                if always_unzip not in ('true', 'false'):
-                    raise zc.buildout.UserError("Invalid value for unzip, %s"
-                                                % always_unzip)
-                kw['always_unzip'] = always_unzip == 'true'
+            if options.get('unzip'):
+                kw['always_unzip'] = get_bool(options, 'unzip')
 
             ws = zc.buildout.easy_install.install(
                 distributions, options['eggs-directory'],
@@ -141,6 +137,15 @@
                     raise zc.buildout.UserError("Invalid entry point")
                 reqs.append(parsed.groups())
 
+            if get_bool(options, 'dependent-scripts'):
+                # generate scripts for all packages in the working set,
+                # except setuptools.
+                reqs = list(reqs)
+                for dist in ws:
+                    name = dist.project_name
+                    if name != 'setuptools' and name not in reqs:
+                        reqs.append(name)
+
             return zc.buildout.easy_install.scripts(
                 reqs, ws, options['executable'],
                 options['bin-directory'],
@@ -155,4 +160,16 @@
 
     update = install
 
+def get_bool(options, name, default=False):
+    value = options.get(name)
+    if not value:
+        return default
+    if value == 'true':
+        return True
+    elif value == 'false':
+        return False
+    else:
+        raise zc.buildout.UserError(
+            "Invalid value for %s: %s" % (name, value))
+
 Egg = Scripts



More information about the Checkins mailing list