[Checkins] SVN: z3c.recipe.eggbasket/trunk/ Add console script 'releasemaker' that can create a basket of eggs.

Maurits van Rees m.van.rees at zestsoftware.nl
Fri May 16 19:48:53 EDT 2008


Log message for revision 86811:
  Add console script 'releasemaker' that can create a basket of eggs.
  

Changed:
  U   z3c.recipe.eggbasket/trunk/CHANGES.txt
  U   z3c.recipe.eggbasket/trunk/buildout.cfg
  U   z3c.recipe.eggbasket/trunk/setup.py
  U   z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt
  U   z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py

-=-
Modified: z3c.recipe.eggbasket/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/CHANGES.txt	2008-05-16 20:11:49 UTC (rev 86810)
+++ z3c.recipe.eggbasket/trunk/CHANGES.txt	2008-05-16 23:48:51 UTC (rev 86811)
@@ -1,9 +1,9 @@
 0.2.0 (unreleased)
 ==================
 
- - Started adding function create_source_tarball for creating the kind
-   of source tarball that we are expecting.  Not hooked up anywhere yet.
-   [maurits]
+ - Added function create_source_tarball for creating the kind of
+   source tarball that we are expecting.  The releasemaker console
+   script calls this.  [maurits]
 
 
 0.1.0 (2008-05-06)

Modified: z3c.recipe.eggbasket/trunk/buildout.cfg
===================================================================
--- z3c.recipe.eggbasket/trunk/buildout.cfg	2008-05-16 20:11:49 UTC (rev 86810)
+++ z3c.recipe.eggbasket/trunk/buildout.cfg	2008-05-16 23:48:51 UTC (rev 86811)
@@ -1,8 +1,17 @@
 [buildout]
 develop = .
-parts = test
+parts = test releasemaker
 
+# This one gives test failures even when "python setup.py test" works
+# fine.  Somehow zc.recipe.egg cannot be found.
 [test]
 recipe = zc.recipe.testrunner
-eggs = z3c.recipe.eggbasket [test]
+eggs = z3c.recipe.eggbasket
 
+# This is really a test for the script.
+[releasemaker]
+recipe = zc.recipe.egg
+eggs = z3c.recipe.eggbasket
+arguments =
+    egg = 'grok',
+    versionfile = 'http://grok.zope.org/releaseinfo/grok-0.12.cfg'

Modified: z3c.recipe.eggbasket/trunk/setup.py
===================================================================
--- z3c.recipe.eggbasket/trunk/setup.py	2008-05-16 20:11:49 UTC (rev 86810)
+++ z3c.recipe.eggbasket/trunk/setup.py	2008-05-16 23:48:51 UTC (rev 86811)
@@ -31,10 +31,7 @@
     'Download\n'
     '********\n'
     )
-entry_point = 'z3c.recipe.eggbasket:Recipe'
-entry_points = {"zc.buildout": ["default = %s" % entry_point]}
 
-tests_require=['zope.testing', 'zc.recipe.egg']
 
 setup(name='z3c.recipe.eggbasket',
       version=version,
@@ -59,11 +56,13 @@
       zip_safe=False,
       install_requires=['setuptools',
                         'zc.buildout',
-                        # -*- Extra requirements: -*-
                         'zc.recipe.egg',
                         ],
-      tests_require=tests_require,
-      extras_require=dict(test=tests_require),
-      test_suite = 'z3c.recipe.eggbasket.tests.test_docs.test_suite',
-      entry_points=entry_points,
+      tests_require=['zope.testing', 'zc.recipe.egg'],
+      test_suite='z3c.recipe.eggbasket.tests.test_docs.test_suite',
+      entry_points={
+        "zc.buildout":
+            ["default = z3c.recipe.eggbasket:Recipe"],
+        'console_scripts':
+            ['releasemaker = z3c.recipe.eggbasket:utils.create_source_tarball']},
       )

Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt	2008-05-16 20:11:49 UTC (rev 86810)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt	2008-05-16 23:48:51 UTC (rev 86811)
@@ -14,11 +14,27 @@
 
 The goal of this recipe is to avoid having those multiple points of
 failure.  You create a tarball containing all eggs that your egg
-depends on.  A package like zc.sourcerelease_ can help here. You
-upload that tarball somewhere.  In your buildout you point this recipe
-to your egg and the url of the tarball, for example like this::
+depends on.  A package like zc.sourcerelease_ can help here, but our
+recipe can also create such a tar ball.  Include it in a buildout like
+this::
 
   [buildout]
+  parts = releasemaker
+
+  [releasemaker]
+  recipe = zc.recipe.egg
+  eggs = z3c.recipe.eggbasket
+  arguments =
+      egg = 'grok',
+      versionfile = 'http://grok.zope.org/releaseinfo/grok-0.12.cfg'
+
+Note the comma that separates the arguments.
+
+After you have made that tar ball, you need to upload it somewhere.
+In your buildout you point this recipe to your egg and the url of the
+tarball, for example like this::
+
+  [buildout]
   parts = eggbasket
 
   [eggbasket]
@@ -67,6 +83,21 @@
     and their dependencies.
 
 
+The releasemaker script supports the following options:
+
+egg
+    The main egg that we want to bundle up with its dependencies.
+    This is required.
+
+versionfile
+    Config file that contains the wanted versions of the main egg and
+    its dependencies.  An example is the grok version file:
+    http://grok.zope.org/releaseinfo/grok-0.12.cfg
+    This file is parsed by zc.buildout, so you can for example extend
+    other files.  And the file can be a url or the name of a file in
+    the current directory.
+
+
 Example usage
 =============
 
@@ -107,7 +138,7 @@
 
     >>> print system(buildout)
     Upgraded:
-      zc.buildout version 1.0.1;
+      zc.buildout version ...;
     restarting.
     Generated script '/sample-buildout/bin/buildout'.
     Installing basket.

Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py	2008-05-16 20:11:49 UTC (rev 86810)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py	2008-05-16 23:48:51 UTC (rev 86811)
@@ -1,3 +1,4 @@
+import sys
 import tempfile
 import shutil
 import tarfile
@@ -30,26 +31,40 @@
     return result
 
 
-def create_source_tarball():
-    # These variables need to be configurable:
-    egg = 'grok'
-    version = '0.13'
-    config_file_name = 'buildout.cfg'
+def create_source_tarball(egg=None, versionfile='buildout.cfg'):
+    # XXX We may want to add command line argument handling.
+
+    if egg is None:
+        # XXX Having a way to read the setup.py in the current
+        # directory and get an egg name and perhaps version number
+        # from there would be cool.  For now:
+        print "Please provide an egg name."
+        sys.exit(1)
+
+    # XXX This may be a bit too hard coded.
+    # Perhaps try to read something from the buildout config.
     links = ['http://download.zope.org/distribution/']
 
     import zc.buildout.easy_install
     import zc.buildout.buildout
     import os
 
-    # Read the buildout file.
-    here = os.getcwd()
-    config_file = os.path.join(here, config_file_name)
-    config = zc.buildout.buildout._open(here, config_file, [])
+    # Read the buildout/versions file.  versionfile can be a file in
+    # the current working directory or on some url.  zc.buildout
+    # nicely takes care of that for us.
+    config = zc.buildout.buildout._open(os.getcwd(), versionfile, [])
 
     # Get the version information.
-    versions = config['buildout'].get('versions')
-    if version is not None:
-        versions = config[versions]
+    buildout = config.get('buildout')
+    if buildout is None:
+        versions = config.get('versions')
+    else:
+        versions = buildout.get('versions')
+        if versions is not None:
+            versions = config.get(versions)
+    if versions is None:
+        print "Could not get versions from %s." % versionfile
+        sys.exit(1)
 
     try:
         # Make temporary directories for the cache and the destination
@@ -60,18 +75,34 @@
         # Set the download cache directory:
         zc.buildout.easy_install.download_cache(cache)
 
+        main_egg_version = versions.get(egg)
+        if main_egg_version is None:
+            print ("Error: the main egg (%s) has not been pinned in the "
+                   "version file (%s)." % (egg, versionfile))
+            sys.exit(1)
+
         # Install the main egg, which pulls all dependencies into the
         # download cache.
+        print ("Will get main egg (%s) version %s and dependencies "
+               "with versions as listed in %s." %
+               (egg, main_egg_version, versionfile))
+        print "This could take a while..."
         ws = zc.buildout.easy_install.install(
             [egg], dest, versions=versions,
             links=links)
 
         # Create tarball in current directory.
-        directory_name = '%s-eggs-%s' % (egg, version)
-        egg_tar = tarfile.open(directory_name + '.tgz', 'w:gz')
+        directory_name = '%s-eggs-%s' % (egg, main_egg_version)
+        tar_name = directory_name + '.tgz'
+        print "Creating", tar_name
+        egg_tar = tarfile.open(tar_name, 'w:gz')
         egg_tar.add(cache, directory_name)
-        # TODO: actually add latest version of grok egg
+
+        # TODO: perhaps actually add latest version of grok egg if it
+        # is not there already, though currently the code should have
+        # failed already when this it is not available.
         egg_tar.close()
+        print "Done."
     finally:
         shutil.rmtree(dest)
         shutil.rmtree(cache)



More information about the Checkins mailing list