[Checkins] SVN: z3c.recipe.eggbasket/trunk/ Created script around create_source_tarball function with the

Maurits van Rees m.van.rees at zestsoftware.nl
Wed May 21 17:46:41 EDT 2008


Log message for revision 86890:
  Created script around create_source_tarball function with the
  z3c.recipe.eggbasket:creator recipe.  Removed the releasemaker
  console script from setup.py for now as it was not handling command
  line arguments (yet).
  

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/__init__.py
  A   z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/creator.py
  A   z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/downloader.py

-=-
Modified: z3c.recipe.eggbasket/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/CHANGES.txt	2008-05-21 21:09:46 UTC (rev 86889)
+++ z3c.recipe.eggbasket/trunk/CHANGES.txt	2008-05-21 21:46:38 UTC (rev 86890)
@@ -1,6 +1,11 @@
 0.2.0 (unreleased)
 ==================
 
+ - Created script around create_source_tarball function with the
+   z3c.recipe.eggbasket:creator recipe.  Removed the releasemaker
+   console script from setup.py for now as it was not handling command
+   line arguments (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]

Modified: z3c.recipe.eggbasket/trunk/buildout.cfg
===================================================================
--- z3c.recipe.eggbasket/trunk/buildout.cfg	2008-05-21 21:09:46 UTC (rev 86889)
+++ z3c.recipe.eggbasket/trunk/buildout.cfg	2008-05-21 21:46:38 UTC (rev 86890)
@@ -1,6 +1,6 @@
 [buildout]
 develop = .
-parts = test releasemaker
+parts = test bundlemaker
 
 # This one gives test failures even when "python setup.py test" works
 # fine.  Somehow zc.recipe.egg cannot be found.
@@ -8,10 +8,8 @@
 recipe = zc.recipe.testrunner
 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'
+
+[bundlemaker]
+recipe = z3c.recipe.eggbasket:creator
+egg = martian
+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-21 21:09:46 UTC (rev 86889)
+++ z3c.recipe.eggbasket/trunk/setup.py	2008-05-21 21:46:38 UTC (rev 86890)
@@ -35,7 +35,7 @@
 
 setup(name='z3c.recipe.eggbasket',
       version=version,
-      description="Install eggs from a tarball.",
+      description="Install eggs from a tarball and create that egg.",
       long_description=long_description,
       # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
       classifiers=[
@@ -62,7 +62,7 @@
       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']},
+            ["default = z3c.recipe.eggbasket:Downloader",
+             "creator = z3c.recipe.eggbasket:Creator",],
+        },
       )

Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt	2008-05-21 21:09:46 UTC (rev 86889)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/README.txt	2008-05-21 21:46:38 UTC (rev 86890)
@@ -19,17 +19,13 @@
 this::
 
   [buildout]
-  parts = releasemaker
+  parts = bundlemaker
 
-  [releasemaker]
-  recipe = zc.recipe.egg
-  eggs = z3c.recipe.eggbasket
-  arguments =
-      egg = 'grok',
-      versionfile = 'http://grok.zope.org/releaseinfo/grok-0.12.cfg'
+  [bundlemaker]
+  recipe = z3c.recipe.eggbasket:creator
+  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::

Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py	2008-05-21 21:09:46 UTC (rev 86889)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py	2008-05-21 21:46:38 UTC (rev 86890)
@@ -1,88 +1,4 @@
 # -*- coding: utf-8 -*-
-"""Recipe eggbasket"""
 
-import logging
-import tempfile
-import shutil
-import os
-import tarfile
-import urllib
-from zc.recipe.egg import Eggs
-from z3c.recipe.eggbasket.utils import distributions_are_installed_in_dir
-from z3c.recipe.eggbasket.utils import install_distributions
-
-
-class Recipe(Eggs):
-    """zc.buildout recipe for getting eggs out of a tar ball"""
-
-    def install(self):
-        """Installer
-        """
-        log = logging.getLogger(self.name)
-        if self.buildout['buildout'].get('offline') == 'true':
-            log.error("Cannot run in offline mode.")
-            return tuple()
-        options = self.options
-
-        distributions = [
-            r.strip()
-            for r in options.get('eggs', self.name).split('\n')
-            if r.strip()]
-
-        if not distributions_are_installed_in_dir(distributions,
-                                                  options['eggs-directory']):
-            log.info("Distributions are not installed. "
-                     "A tarball will be downloaded.")
-            url = self.options.get('url')
-            tarball_name = url.split('/')[-1]
-            log.info("Downloading %s ..." % url)
-
-            try:
-                # Make temporary files and directories.
-                extraction_dir = tempfile.mkdtemp()
-                filenum, temp_tarball_name = tempfile.mkstemp()
-
-                tarball = open(temp_tarball_name, 'w')
-                try:
-                    tarball.write(urllib.urlopen(url).read())
-                except IOError:
-                    log.error("Url not found: %s." % url)
-                    return tuple()
-                tarball.close()
-                log.info("Finished downloading.")
-                log.info("Extracting tarball contents...")
-
-                try:
-                    tf = tarfile.open(temp_tarball_name, 'r:gz')
-                except tarfile.ReadError, e:
-                    # Likely the download location is wrong and gives a 404.
-                    # Or the tarball is not zipped.
-                    log.error("No correct tarball found at %s." % url)
-                    log.error("The error was: %s" % e)
-                    return tuple()
-
-                links = []
-                for name in tf.getnames():
-                    tf.extract(name, extraction_dir)
-                    links.append(os.path.join(extraction_dir, name))
-                tf.close()
-
-                log.info("Installing eggs to %s which will take a while..."
-                         % options['eggs-directory'])
-                result = install_distributions(
-                    distributions, options['eggs-directory'],
-                    links = links)
-                if result is False:
-                    log.error("Failed to install required eggs with the tar "
-                              "ball. Continuing with buildout instead.")
-            finally:
-                shutil.rmtree(extraction_dir)
-                os.unlink(temp_tarball_name)
-
-        # Return files that were created by the recipe. The buildout
-        # will remove all returned files upon reinstall.
-        return tuple()
-
-    def update(self):
-        # This recipe only needs to be called once.
-        pass
+from z3c.recipe.eggbasket.downloader import Downloader
+from z3c.recipe.eggbasket.creator import Creator

Added: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/creator.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/creator.py	                        (rev 0)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/creator.py	2008-05-21 21:46:38 UTC (rev 86890)
@@ -0,0 +1,45 @@
+# Copied from zc/recipe/testrunner/__init__.py mostly.
+
+import os
+import zc.buildout.easy_install
+import zc.recipe.egg
+
+
+class Creator(object):
+
+    def __init__(self, buildout, name, options):
+        self.buildout = buildout
+        self.name = name
+        self.options = options
+        options['script'] = os.path.join(buildout['buildout']['bin-directory'],
+                                         options.get('script', self.name),
+                                         )
+        # The generated script needs our own recipe plus dependencies
+        # in the path, which is neatly done with this call:
+        self.egg = zc.recipe.egg.Egg(buildout, 'z3c.recipe.eggbasket', options)
+
+    def install(self):
+        options = self.options
+        dest = []
+        eggs, ws = self.egg.working_set()
+
+        dest.extend(zc.buildout.easy_install.scripts(
+            [(options['script'], 'z3c.recipe.eggbasket.utils',
+              'create_source_tarball')],
+            ws, options['executable'],
+            self.buildout['buildout']['bin-directory'],
+            extra_paths=self.egg.extra_paths,
+            arguments = (arg_template % dict(
+                        egg=options['egg'],
+                        versionfile=options['versionfile'],
+                        )),
+            ))
+
+        return dest
+
+    update = install
+
+
+arg_template = """
+        egg = '%(egg)s',
+        versionfile = '%(versionfile)s'"""


Property changes on: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/creator.py
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/downloader.py (from rev 86886, z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py)
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/downloader.py	                        (rev 0)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/downloader.py	2008-05-21 21:46:38 UTC (rev 86890)
@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-
+"""Recipe eggbasket"""
+
+import logging
+import tempfile
+import shutil
+import os
+import tarfile
+import urllib
+from zc.recipe.egg import Eggs
+from z3c.recipe.eggbasket.utils import distributions_are_installed_in_dir
+from z3c.recipe.eggbasket.utils import install_distributions
+
+
+class Downloader(Eggs):
+    """zc.buildout recipe for getting eggs out of a tar ball"""
+
+    def install(self):
+        """Installer
+        """
+        log = logging.getLogger(self.name)
+        if self.buildout['buildout'].get('offline') == 'true':
+            log.error("Cannot run in offline mode.")
+            return tuple()
+        options = self.options
+
+        distributions = [
+            r.strip()
+            for r in options.get('eggs', self.name).split('\n')
+            if r.strip()]
+
+        if not distributions_are_installed_in_dir(distributions,
+                                                  options['eggs-directory']):
+            log.info("Distributions are not installed. "
+                     "A tarball will be downloaded.")
+            url = self.options.get('url')
+            tarball_name = url.split('/')[-1]
+            log.info("Downloading %s ..." % url)
+
+            try:
+                # Make temporary files and directories.
+                extraction_dir = tempfile.mkdtemp()
+                filenum, temp_tarball_name = tempfile.mkstemp()
+
+                tarball = open(temp_tarball_name, 'w')
+                try:
+                    tarball.write(urllib.urlopen(url).read())
+                except IOError:
+                    log.error("Url not found: %s." % url)
+                    return tuple()
+                tarball.close()
+                log.info("Finished downloading.")
+                log.info("Extracting tarball contents...")
+
+                try:
+                    tf = tarfile.open(temp_tarball_name, 'r:gz')
+                except tarfile.ReadError, e:
+                    # Likely the download location is wrong and gives a 404.
+                    # Or the tarball is not zipped.
+                    log.error("No correct tarball found at %s." % url)
+                    log.error("The error was: %s" % e)
+                    return tuple()
+
+                links = []
+                for name in tf.getnames():
+                    tf.extract(name, extraction_dir)
+                    links.append(os.path.join(extraction_dir, name))
+                tf.close()
+
+                log.info("Installing eggs to %s which will take a while..."
+                         % options['eggs-directory'])
+                result = install_distributions(
+                    distributions, options['eggs-directory'],
+                    links = links)
+                if result is False:
+                    log.error("Failed to install required eggs with the tar "
+                              "ball. Continuing with buildout instead.")
+            finally:
+                shutil.rmtree(extraction_dir)
+                os.unlink(temp_tarball_name)
+
+        # Return files that were created by the recipe. The buildout
+        # will remove all returned files upon reinstall.
+        return tuple()
+
+    def update(self):
+        # This recipe only needs to be called once.
+        pass



More information about the Checkins mailing list