[Checkins] SVN: z3c.recipe.eggbasket/trunk/ initial implementation,
taking code from current grokproject
Maurits van Rees
m.van.rees at zestsoftware.nl
Mon May 5 08:57:49 EDT 2008
Log message for revision 86448:
initial implementation, taking code from current grokproject
Changed:
U z3c.recipe.eggbasket/trunk/CHANGES.txt
U z3c.recipe.eggbasket/trunk/CONTRIBUTORS.txt
U z3c.recipe.eggbasket/trunk/README.txt
U z3c.recipe.eggbasket/trunk/setup.py
U z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py
A z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
-=-
Modified: z3c.recipe.eggbasket/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/CHANGES.txt 2008-05-05 12:53:57 UTC (rev 86447)
+++ z3c.recipe.eggbasket/trunk/CHANGES.txt 2008-05-05 12:57:48 UTC (rev 86448)
@@ -1,4 +1,6 @@
0.1.0 (xxxx-xx-xx)
==================
+ - Initial implementation. [maurits, timte]
+
- Created recipe with ZopeSkel [Grok Team].
Modified: z3c.recipe.eggbasket/trunk/CONTRIBUTORS.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/CONTRIBUTORS.txt 2008-05-05 12:53:57 UTC (rev 86447)
+++ z3c.recipe.eggbasket/trunk/CONTRIBUTORS.txt 2008-05-05 12:57:48 UTC (rev 86448)
@@ -1,2 +1,4 @@
-Grok Team, Author
+Grok Team:
+Maurits van Rees
+Tim Terlegard
Modified: z3c.recipe.eggbasket/trunk/README.txt
===================================================================
--- z3c.recipe.eggbasket/trunk/README.txt 2008-05-05 12:53:57 UTC (rev 86447)
+++ z3c.recipe.eggbasket/trunk/README.txt 2008-05-05 12:57:48 UTC (rev 86448)
@@ -5,4 +5,4 @@
Update the following URL to point to your code repository or remove
it if one is not available.
-Code repository: http://svn.somewhere.com/...
+Code repository: 'http://svn.zope.org/*checkout*/z3c.recipe.eggbasket/trunk
Modified: z3c.recipe.eggbasket/trunk/setup.py
===================================================================
--- z3c.recipe.eggbasket/trunk/setup.py 2008-05-05 12:53:57 UTC (rev 86447)
+++ z3c.recipe.eggbasket/trunk/setup.py 2008-05-05 12:57:48 UTC (rev 86448)
@@ -54,12 +54,13 @@
url='https://launchpad.net/grok',
license='ZPL',
packages=find_packages(exclude=['ez_setup']),
- namespace_packages=['z3c.recipe'],
+ namespace_packages=['z3c', 'z3c.recipe'],
include_package_data=True,
zip_safe=False,
install_requires=['setuptools',
- 'zc.buildout'
+ 'zc.buildout',
# -*- Extra requirements: -*-
+ 'zc.recipe.egg',
],
tests_require=tests_require,
extras_require=dict(tests=tests_require),
Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py 2008-05-05 12:53:57 UTC (rev 86447)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/__init__.py 2008-05-05 12:57:48 UTC (rev 86448)
@@ -1,22 +1,85 @@
# -*- coding: utf-8 -*-
"""Recipe eggbasket"""
-from zc.buildout import UserError
+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(object):
- """zc.buildout recipe"""
- def __init__(self, buildout, name, options):
- self.buildout, self.name, self.options = buildout, name, options
+class Recipe(Eggs):
+ """zc.buildout recipe for getting eggs out of a tar ball"""
def install(self):
- """Installer"""
- # XXX Implement recipe functionality here
-
+ """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("Grok is not installed. "
+ "A grok 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("Installing eggs to %s which will take a while..."
+ % options['eggs-directory'])
+
+ try:
+ tf = tarfile.open(temp_tarball_name,
+ 'r:gz')
+ except tarfile.ReadError:
+ # Likely the download location is wrong and gives a 404.
+ log.error("No correct tarball found at %s." % url)
+ 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 grok. This will take a while...")
+ 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):
- """Updater"""
- pass
+ update = install
Added: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py (rev 0)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py 2008-05-05 12:57:48 UTC (rev 86448)
@@ -0,0 +1,29 @@
+import tempfile
+import shutil
+
+
+def install_distributions(distributions, target_dir, links=[]):
+ from zc.buildout.easy_install import install
+ from zc.buildout.easy_install import MissingDistribution
+ try:
+ empty_index = tempfile.mkdtemp()
+
+ try:
+ install(distributions, target_dir, newest=False,
+ links=links, index='file://' + empty_index)
+ except MissingDistribution:
+ return False
+ else:
+ return True
+ finally:
+ shutil.rmtree(empty_index)
+
+
+def distributions_are_installed_in_dir(distributions, target_dir):
+ # Check if the required distributions are installed. We do this
+ # by trying to install the distributions in the target dir and
+ # letting easy_install only look inside that same target dir while
+ # doing that.
+ result = install_distributions(distributions, target_dir,
+ links=[target_dir])
+ return result
Property changes on: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list