[Checkins] SVN: zc.sourcerelease/branches/dev/ Checkpointing.

Jim Fulton jim at zope.com
Tue Oct 23 19:34:34 EDT 2007


Log message for revision 80983:
  Checkpointing.
  

Changed:
  A   zc.sourcerelease/branches/dev/README.txt
  A   zc.sourcerelease/branches/dev/buildout.cfg
  U   zc.sourcerelease/branches/dev/sample/release.cfg
  A   zc.sourcerelease/branches/dev/setup.py
  A   zc.sourcerelease/branches/dev/src/
  A   zc.sourcerelease/branches/dev/src/zc/
  A   zc.sourcerelease/branches/dev/src/zc/__init__.py
  A   zc.sourcerelease/branches/dev/src/zc/sourcerelease/
  A   zc.sourcerelease/branches/dev/src/zc/sourcerelease/README.txt
  A   zc.sourcerelease/branches/dev/src/zc/sourcerelease/__init__.py
  A   zc.sourcerelease/branches/dev/src/zc/sourcerelease/tests.py

-=-
Added: zc.sourcerelease/branches/dev/README.txt
===================================================================
--- zc.sourcerelease/branches/dev/README.txt	                        (rev 0)
+++ zc.sourcerelease/branches/dev/README.txt	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1 @@
+See README.txt in the zc.sourcerelease package.


Property changes on: zc.sourcerelease/branches/dev/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.sourcerelease/branches/dev/buildout.cfg
===================================================================
--- zc.sourcerelease/branches/dev/buildout.cfg	                        (rev 0)
+++ zc.sourcerelease/branches/dev/buildout.cfg	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1,14 @@
+
+[buildout]
+develop = .
+parts = script
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = zc.sourcerelease
+
+
+[script]
+recipe = zc.recipe.egg
+eggs = ${test:eggs}
+interpreter = py


Property changes on: zc.sourcerelease/branches/dev/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: zc.sourcerelease/branches/dev/sample/release.cfg
===================================================================
--- zc.sourcerelease/branches/dev/sample/release.cfg	2007-10-23 22:46:43 UTC (rev 80982)
+++ zc.sourcerelease/branches/dev/sample/release.cfg	2007-10-23 23:34:33 UTC (rev 80983)
@@ -1,21 +1,18 @@
 [buildout]
-parts = zodb test extra-eggs
+parts = zodb test
 versions = versions
 
 [versions]
 setuptools = 0.6c7
-zc.buildout = 1.0.0b30
-ZConfig = 2.4a2
-zc.recipe.deployment = 0.5
+zc.buildout = 1.0.0b29
+ZConfig = 2.5
 zc.recipe.egg = 1.0.0b6
-zc.recipe.rhrc = 0.1dev-r72230
-zc.recipe.testrunner = 1.0.0b7
-zc.zodbrecipes = 0.2.1
-zdaemon = 2.0a6
-ZODB3 = 3.8.0b3
-zope.interface = 3.4.0a1
+zc.recipe.testrunner = 1.0.0b8
+zdaemon = 2.0.0
+ZODB3 = 3.8.0b4
+zope.interface = 3.4.1
 zope.proxy = 3.4.0
-zope.testing = 3.4
+zope.testing = 3.5.1
 
 [zodb]
 recipe = zc.recipe.egg:script
@@ -25,15 +22,3 @@
 [test]
 recipe = zc.recipe.testrunner
 eggs = ZODB3
-
-[buildout]
-extends = buildout.cfg
-parts = zodb test extra-eggs mercury
-
-[extra-eggs]
-recipe = zc.recipe.egg:eggs
-eggs =
-   zc.zodbrecipes
-   zc.recipe.rhrc
-   zc.recipe.deployment
-   buildoutmercury

Added: zc.sourcerelease/branches/dev/setup.py
===================================================================
--- zc.sourcerelease/branches/dev/setup.py	                        (rev 0)
+++ zc.sourcerelease/branches/dev/setup.py	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1,27 @@
+from setuptools import setup, find_packages
+
+entry_points = """
+[console_scripts]
+buildout-source-release = zc.sourcerelease:source_release
+"""
+
+setup(
+    name = "zc.sourcerelease",
+    description = "Utility script to create source releases from buildouts",
+    version = ".1",
+    license = "ZPL 1.0",
+    url='http://www.python.org/pypi/zc.sourcerelease',
+    author='Jim Fulton', author_email='jim at zope.com',
+    
+    entry_points = entry_points,
+    packages = find_packages('src'),
+    include_package_data = True,
+    zip_safe = False,
+    package_dir = {'':'src'},
+    namespace_packages = ['zc'],
+    install_requires = [
+        'setuptools',
+        'zc.buildout',
+        'zc.recipe.egg',
+        ],
+    )


Property changes on: zc.sourcerelease/branches/dev/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.sourcerelease/branches/dev/src/zc/__init__.py
===================================================================
--- zc.sourcerelease/branches/dev/src/zc/__init__.py	                        (rev 0)
+++ zc.sourcerelease/branches/dev/src/zc/__init__.py	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)


Property changes on: zc.sourcerelease/branches/dev/src/zc/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.sourcerelease/branches/dev/src/zc/sourcerelease/README.txt
===================================================================
--- zc.sourcerelease/branches/dev/src/zc/sourcerelease/README.txt	                        (rev 0)
+++ zc.sourcerelease/branches/dev/src/zc/sourcerelease/README.txt	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1,101 @@
+Creating Source Releases from Buildouts
+=======================================
+
+The zc.sourcerelease package provides a script,
+buildout-source-release, that generates a source release from a
+buildout.  The source release, in the form of a gzipped tar archive
+[#zip_in_future]_.  The generated source release can be used as the
+basis for higher-level releases, such as RPMs or
+configure-make-make-install releases.
+
+The source releases includes data that would normally be installed in
+a download cache, such as Python distributions, or downloads performed
+by the zc.recipe.cmmi recipe.  If a buildout uses a recipe that
+downloads data but does not store the downloaded data in the buildout
+download cache, then the data will not be included in the source
+release and will have to be downloaded when the source release is
+installed. 
+
+The source release includes a Python install script.  It is not
+executable and is run with the desired Python.  The install script
+runs the buildout in place.  This means that
+the source release will need to be extracted to and the buildout run
+in the final install location [#separate_install_step]_.  While the
+install script can be used directly, it will more commonly be used by
+system-packaging (e.g. RPM) build scripts or make files.
+
+To create a source release, simply run the buildout-source-release
+script, passing a file URL or a subversion URL
+[#other_source_code_control_systems]_ and the name of the
+configuration file to use.  File URLs are useful for testing and can
+be used with non-subversion source-code control systems.
+
+Let's look at an example.  We have a server with some distributions on
+it. 
+
+    >>> print get(link_server),
+
+We also have a sample buildout in which we'll install the
+buildout-source-release script:
+
+    >>> write('buildout.cfg', 
+    ... '''
+    ... [buildout]
+    ... parts = script
+    ... find-links = %(link_server)s
+    ... 
+    ... [script]
+    ... recipe = zc.recipe.egg
+    ... eggs = zc.sourcerelease
+    ... ''' % globals())
+
+    >>> print system(buildout), # doctest: +ELLIPSIS
+    Getting distribution for 'zc.recipe.egg'.
+    ...
+    Generated script '/sample-buildout/bin/buildout-source-release'.
+
+
+This just gets us the script.  Now we'll create another buildout that
+we'll use for our source release.  
+
+    >>> mkdir('sample')
+    >>> sample = join(sample_buildout, 'sample')
+    >>> write(sample, 'buildout.cfg', 
+    ... '''
+    ... [buildout]
+    ... parts = sample
+    ... find-links = %(link_server)s
+    ... 
+    ... [sample]
+    ... recipe = zc.recipe.egg
+    ... eggs = sample1
+    ... ''' % globals())
+
+We'll run the release script against this sample directory:
+
+    >>> print system(join('bin', 'buildout-source-release')
+    ...        +' file://'+join(sample)+' buildout.cfg'),
+
+What we end up with is a tar file:
+
+    >>> ls()
+
+Let's copy the tar file to a temporary directory:
+
+    >>> mkdir('test')
+    >>> import tarfile
+    >>> tf = tarfile.open('sample.tgz', 'r:gz')
+    >>> tf.extract('sample', 'test')
+    >>> ls('test')
+
+.. [#zip_in_future] It is possible that an option will be added in the
+future to generate zip files rather than tar archives.
+
+.. [#separate_install_step] In the future, it is likely that we'll
+also support a model in which the install script can install to a
+separate location.  Buildouts will have to take this into account,
+providing for copying necessary files, other than just scripts and
+eggs, into the destination directory.
+
+.. [#other_source_code_control_systems] Other source
+code control systems may be supported in the future.


Property changes on: zc.sourcerelease/branches/dev/src/zc/sourcerelease/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.sourcerelease/branches/dev/src/zc/sourcerelease/__init__.py
===================================================================
--- zc.sourcerelease/branches/dev/src/zc/sourcerelease/__init__.py	                        (rev 0)
+++ zc.sourcerelease/branches/dev/src/zc/sourcerelease/__init__.py	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1,115 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+import shutil
+import subprocess
+import sys
+import tarfile
+import tempfile
+import urlparse
+
+import pkg_resources
+
+import zc.buildout.buildout
+
+def _system(*args):
+    p = subprocess.Popen(args)
+    r = p.wait()
+    if r:
+        raise SystemError("Subprocess failed!")
+    
+def source_release(args=None):
+    if args is None:
+        args = sys.argv[1:]
+    [url, config] = args
+    name = url.split('/')[-1]
+    t1 = tempfile.mkdtemp('source-release1')
+    t2 = tempfile.mkdtemp('source-release2')
+    co1 = os.path.join(t1, name)
+    co2 = os.path.join(t2, name)
+    here = os.getcwd()
+    try:
+
+        if url.startswith('file://'):
+            shutil.copytree(urlparse.urlparse(url)[2], co1)
+        else:
+            system('svn', 'export', url, co1)
+        shutil.copytree(co1, co2)
+        cache = os.path.join(co2, 'release-distributions')
+        os.mkdir(cache)
+        buildout = zc.buildout.buildout.Buildout(
+            os.path.join(co1, config),
+            [('buildout', 'download-cache', cache),
+             ('buildout', 'verbosity', '10'),
+             ],
+            False, False, 'install',
+            )
+        buildout.install([])
+        os.chdir(here)
+
+        env = pkg_resources.Environment([
+            buildout['buildout']['eggs-directory']
+            ])
+        dists = [env[project][0].location
+                 for project in ('zc.buildout', 'setuptools')
+                 ]
+        eggs = os.path.join(co2, 'eggs')
+        os.mkdir(eggs)
+        for dist in dists:
+            if os.path.isdir(dist):
+                shutil.copytree(dist,
+                                os.path.join(eggs, os.path.basename(dist))
+                                )
+            else:
+                shutil.copy(dist, eggs)
+
+        open(os.path.join(co2, 'install.py'), 'w').write(
+            install_template % dict(
+                path = [os.path.basename(dist) for dist in dists],
+                config = config,
+                version = sys.version_info[:2],
+            ))
+
+        
+        tar = tarfile.open(name+'.tgz', 'w:gz')
+        tar.add(co2, name)
+        tar.close()
+
+
+    finally:
+        shutil.rmtree(t1)
+        shutil.rmtree(t2)
+
+install_template = """
+import os, sys
+
+if sys.version_info[:2] != %(version)r:
+    print "Invalid Python version, %%s.%%s." %% sys.version_info[:2]
+    print "Python %%s.%%s is required." %% %(version)r
+    sys.exit(1)
+
+sys.path[0:0] = [
+    os.path.join('eggs', dist)
+    for dist in %(path)r
+    ]
+config = %(config)r
+
+import zc.buildout.buildout
+zc.buildout.buildout.main([
+    '-Uc', config,
+    'buildout:download-cache=release-distributions',
+    'buildout:install-from-cache=true',
+    ]+sys.argv[1:])
+"""


Property changes on: zc.sourcerelease/branches/dev/src/zc/sourcerelease/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.sourcerelease/branches/dev/src/zc/sourcerelease/tests.py
===================================================================
--- zc.sourcerelease/branches/dev/src/zc/sourcerelease/tests.py	                        (rev 0)
+++ zc.sourcerelease/branches/dev/src/zc/sourcerelease/tests.py	2007-10-23 23:34:33 UTC (rev 80983)
@@ -0,0 +1,105 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+import shutil
+import tempfile
+import unittest
+import zipfile
+
+import pkg_resources
+
+from zope.testing import doctest, renormalizing
+
+import zc.buildout.testing
+
+
+def mkdist(dest, name, **kw):
+    options = dict(name=name, version='1.0',
+                   url='http://www.zope.org',
+                   author='bob', author_email='bob at foo.com')
+    options.update(kw)
+    d = tempfile.mkdtemp('mkdist')
+    try:
+        open(os.path.join(d, 'README'), 'w').write('')
+        open(os.path.join(d, name+'.py'), 'w').write(py_template % name)
+        open(os.path.join(d, 'setup.py'), 'w').write(setup_template % dict(
+            name = name,
+            options = options,
+            ))
+        zc.buildout.testing.sdist(d, dest)
+    finally:
+        shutil.rmtree(d)
+
+py_template = """
+def main():
+    print 'Hello. My name is ', %r 
+
+"""
+
+setup_template = """
+from setuptools import setup
+setup(py_modules=[%(name)r],
+      entry_points = {'console_scripts': ['%(name)s=%(name)s:main']},
+      **%(options)r)
+"""
+
+def copy_egg(src, dest):
+    if os.path.isdir(src):
+        zip = zipfile.ZipFile(os.path.join(dest, os.path.basename(src)), 'w')
+        lprefix = len(src)+1
+        for dir, dirs, files in os.walk(src):
+            for file in files:
+                path = os.path.join(dir, file)
+                zip.write(path, path[lprefix:])
+        zip.close()
+    else:
+        shutil.copy(src, dest)
+
+def setUp(test):
+    zc.buildout.testing.buildoutSetUp(test)
+    sample_eggs = test.globs['tmpdir']('sample_eggs')
+    test.globs['sample_eggs'] = sample_eggs
+    os.mkdir(os.path.join(sample_eggs, 'index'))
+    mkdist(sample_eggs, 'sample1', install_requires=['sample2'])
+    mkdist(sample_eggs, 'sample2')
+    test.globs['link_server'] = test.globs['start_server'](
+        test.globs['sample_eggs'])
+
+    for project in ('zc.sourcerelease', 'zc.recipe.egg', 'zc.buildout',
+                    'setuptools'):
+        dist = pkg_resources.working_set.find(
+            pkg_resources.Requirement.parse(project))
+        copy_egg(dist.location, sample_eggs)
+        if dist.precedence == pkg_resources.DEVELOP_DIST:
+            zc.buildout.testing.sdist(os.path.dirname(dist.location),
+                                      sample_eggs)
+        else:
+            copy_egg(dist.location, sample_eggs)
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocFileSuite(
+        'README.txt',
+        setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
+        checker=renormalizing.RENormalizing([
+               zc.buildout.testing.normalize_path,
+               zc.buildout.testing.normalize_egg_py,
+               ]),
+        ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: zc.sourcerelease/branches/dev/src/zc/sourcerelease/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Checkins mailing list