[Checkins] SVN: z3c.recipe.eggbasket/trunk/ Started adding function create_source_tarball for creating the kind of

Maurits van Rees m.van.rees at zestsoftware.nl
Fri May 9 22:14:11 EDT 2008


Log message for revision 86599:
  Started adding function create_source_tarball for creating the kind of
  source tarball that we are expecting.  Not hooked up anywhere yet.
  

Changed:
  U   z3c.recipe.eggbasket/trunk/CHANGES.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-10 01:37:38 UTC (rev 86598)
+++ z3c.recipe.eggbasket/trunk/CHANGES.txt	2008-05-10 02:14:10 UTC (rev 86599)
@@ -1,7 +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]
 
 
 0.1.0 (2008-05-06)

Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py	2008-05-10 01:37:38 UTC (rev 86598)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py	2008-05-10 02:14:10 UTC (rev 86599)
@@ -1,5 +1,6 @@
 import tempfile
 import shutil
+import tarfile
 
 
 def install_distributions(distributions, target_dir, links=[]):
@@ -27,3 +28,50 @@
     result = install_distributions(distributions, target_dir,
                                    links=[target_dir])
     return result
+
+
+def create_source_tarball():
+    # These variables need to be configurable:
+    egg = 'grok'
+    version = '0.13'
+    config_file_name = 'buildout.cfg'
+    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, [])
+
+    # Get the version information.
+    versions = config['buildout'].get('versions')
+    if version is not None:
+        versions = config[versions]
+
+    try:
+        # Make temporary directories for the cache and the destination
+        # eggs directory.  The cache is the important one here as that is
+        # where the sources get downloaded to.
+        cache = tempfile.mkdtemp()
+        dest = tempfile.mkdtemp()
+        # Set the download cache directory:
+        zc.buildout.easy_install.download_cache(cache)
+
+        # Install the main egg, which pulls all dependencies into the
+        # download cache.
+        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')
+        egg_tar.add(cache, directory_name)
+        # TODO: actually add latest version of grok egg
+        egg_tar.close()
+    finally:
+        shutil.rmtree(dest)
+        shutil.rmtree(cache)



More information about the Checkins mailing list