[Erp5-report] r30856 - in /erp5/trunk/utils/erp5.recipe: ./ src/ src/erp5/ src/erp5/recipe/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 25 15:35:52 CET 2009
Author: kazuhiko
Date: Wed Nov 25 15:35:51 2009
New Revision: 30856
URL: http://svn.erp5.org?rev=30856&view=rev
Log:
initial import of erp5.recipe package.
Added:
erp5/trunk/utils/erp5.recipe/
erp5/trunk/utils/erp5.recipe/CHANGES.txt (with props)
erp5/trunk/utils/erp5.recipe/README.txt (with props)
erp5/trunk/utils/erp5.recipe/setup.py
erp5/trunk/utils/erp5.recipe/src/
erp5/trunk/utils/erp5.recipe/src/erp5/
erp5/trunk/utils/erp5.recipe/src/erp5/__init__.py
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/__init__.py
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/genbt5list.py
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/run_unit_test.py
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2install.py
erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2instance.py
Added: erp5/trunk/utils/erp5.recipe/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/CHANGES.txt?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/CHANGES.txt (added)
+++ erp5/trunk/utils/erp5.recipe/CHANGES.txt [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,8 @@
+Changelog
+=========
+
+0.1 (2009-11-25)
+----------------
+
+- Initial implementation.
+ [kazuhiko]
Propchange: erp5/trunk/utils/erp5.recipe/CHANGES.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: erp5/trunk/utils/erp5.recipe/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/README.txt?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/README.txt (added)
+++ erp5/trunk/utils/erp5.recipe/README.txt [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,75 @@
+Introduction
+============
+
+This package is a collection of recipes that are useful for ERP5.
+
+genbt5list
+ This recipe creates bt5list file based on business templates.
+
+run_unit_test
+ This recipe creates bin/runUnitTest script.
+
+zope2install
+ This recipe is a patched version of plone.recipe.zope2install that
+ supports 'patch' option so install Zope version 2.8 with the aq_dynamic
+ patch.
+
+zope2instance
+ This recipe is a patched version of plone.recipe.zope2instance that
+ creates more directories required by ERP5.
+
+Example
+=======
+
+You can use them with a part like this::
+
+ [bt5list]
+ recipe = recipes:genbt5list
+ bt5_base = ${download_bt5:location}
+ bt5_urls = ${download_bt5:urls}
+ genbt5list = ${products-erp5:location}/ERP5/bin/genbt5list
+
+ [runUnitTest]
+ recipe = recipes:run_unit_test
+ zope2-location = ${zope2:location}
+ products = ${erp5_instance:products}
+ eggs = ${erp5_instance:eggs}
+ bt5_path = ${download_bt5:location}
+
+ [zope2]
+ recipe = recipes:zope2install
+ url = http://www.zope.org/Products/Zope/2.8.11/Zope-2.8.11-final.tgz
+ patch = patches/Zope-2.8.0-final-aq_dynamic.patch
+
+ [erp5_instance]
+ recipe = erp5.recipe:zope2instance
+ zope2-location = ${zope2:location}
+ user = zope:zope
+ http-address = 18080
+
+Options
+=======
+
+genbt5list
+----------
+
+To be written.
+
+run_unit_test
+-------------
+
+To be written.
+
+zope2install
+------------
+
+patch
+ The path to the patch to be applied. Please note that the patch will be
+ applied with 'patch -p1' command.
+
+See plone.recipe.zope2install's document for other options.
+
+zope2instance
+-------------
+
+See plone.recipe.zope2instance's document for options.
Propchange: erp5/trunk/utils/erp5.recipe/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: erp5/trunk/utils/erp5.recipe/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/setup.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/setup.py (added)
+++ erp5/trunk/utils/erp5.recipe/setup.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,43 @@
+from setuptools import setup, find_packages
+
+name = "erp5.recipe"
+version = '0.1'
+
+def read(name):
+ return open(name).read()
+
+long_description=(
+ read('README.txt')
+ + '\n' +
+ read('CHANGES.txt')
+ )
+
+setup(
+ name = name,
+ version = version,
+ author = "Kazuhiko Shiozaki",
+ author_email = "kazuhiko at nexedi.com",
+ description = "ZC Buildout recipe for installing an ERP5 instance",
+ long_description=long_description,
+ license = "ZPL 2.1",
+ keywords = "zope2 buildout",
+ url='http://pypi.python.org/pypi/erp5.recipe',
+ classifiers=[
+ "License :: OSI Approved :: Zope Public License",
+ "Framework :: Buildout",
+ "Framework :: Zope2",
+ ],
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['erp5', 'erp5.recipe'],
+ install_requires = [
+ 'plone.recipe.zope2install',
+ 'plone.recipe.zope2instance',
+ ],
+ zip_safe=False,
+ entry_points={'zc.buildout': ['zope2install = zope2install:Recipe',
+ 'zope2instance = zope2instance:Recipe',
+ 'genbt5list = genbt5list:Recipe',
+ 'run_unit_test = run_unit_test:Recipe']},
+ )
Added: erp5/trunk/utils/erp5.recipe/src/erp5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/__init__.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/__init__.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Added: erp5/trunk/utils/erp5.recipe/src/erp5/recipe/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/recipe/__init__.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/recipe/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/recipe/__init__.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Added: erp5/trunk/utils/erp5.recipe/src/erp5/recipe/genbt5list.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/recipe/genbt5list.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/recipe/genbt5list.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/recipe/genbt5list.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,55 @@
+import os
+import logging
+import shutil
+
+import zc.buildout
+
+class Recipe(object):
+
+ def __init__(self, buildout, name, options):
+ self.buildout, self.options, self.name = buildout, options, name
+ self.logger=logging.getLogger(self.name)
+
+ options.setdefault('executable',
+ self.buildout['buildout']['executable'])
+
+ options['location'] = os.path.join(
+ buildout['buildout']['parts-directory'],
+ self.name,
+ )
+
+
+ def install(self):
+ options = self.options
+ location = options['location']
+
+ if os.path.exists(location):
+ shutil.rmtree(location)
+ os.mkdir(location)
+
+ base = options['bt5_base']
+ os.chdir(base)
+ for url in options.get('bt5_urls', '').splitlines():
+ if not url:
+ continue
+ url_base, bt5 = url.split()
+ if bt5[-1] == '/':
+ bt5 = bt5[:-1]
+ self.logger.info("Creating bt5 %s" % bt5)
+ assert os.spawnlp(
+ os.P_WAIT, 'tar', 'tar',
+ '--exclude=.svn', '-czf',
+ os.path.join(location, '%s.bt5' % bt5), bt5) == 0
+
+ os.chdir(location)
+ self.logger.info("Generating bt5list")
+ assert os.spawnlp(
+ os.P_WAIT, 'python',
+ zc.buildout.easy_install._safe_arg(options['executable']),
+ zc.buildout.easy_install._safe_arg(options['genbt5list']),
+ ) == 0
+
+ return location
+
+ update = install
+
Added: erp5/trunk/utils/erp5.recipe/src/erp5/recipe/run_unit_test.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/recipe/run_unit_test.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/recipe/run_unit_test.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/recipe/run_unit_test.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,175 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 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, re, shutil, sys, glob
+import zc.buildout
+import zc.recipe.egg
+
+class Recipe:
+ '''Creates a runUnitTest aware of eggs and custom paths used in this
+ buildout.
+ '''
+ name = 'runUnitTest'
+
+ def __init__(self, buildout, name, options):
+ self.buildout, self.options, self.name = buildout, options, name
+
+ self.location = options['location'] = os.path.join(
+ buildout['buildout']['parts-directory'],
+ self.name,
+ )
+ try:
+ self.instance_home = (options.get('instance-home') or
+ # backward compatibility...
+ self.buildout['erp5_instance']['location'])
+ except KeyError:
+ raise RuntimeError('please specify location of ERP5 instance '
+ '(e.g.: "instance-home = '
+ '${erp5_instance:location}")')
+ # force the generation of a single script...
+ scriptName = options.get('control-script', name)
+ options['scripts'] = scriptName + '=runUnitTest'
+ # ...manually defined by our entry point
+ options['entry-points'] = '''
+ runUnitTest=Products.ERP5Type.tests.runUnitTest:main
+ '''
+ # initialize the recipe that will actually generate the script
+ self.egg = zc.recipe.egg.Egg(buildout, 'recipes', options)
+
+ def install(self):
+ options = self.options
+ location = self.location
+
+ extra_paths = self.egg.extra_paths
+ # insert software-home into extra_paths, calculating from
+ # zope2-location if necessary
+ software_home = options.get('software-home')
+ zope2_location = options.get('zope2-location')
+ if zope2_location and not software_home:
+ software_home = os.path.join(zope2_location, 'lib', 'python')
+ if software_home:
+ extra_paths.insert(0, software_home)
+ zope_scripts = None
+ else:
+ # if no software_home can be found, assume software_home is already
+ # reachable by eggs or extra-paths (the generated script will check
+ # if that is the case), but then the skeletons on
+ # ERP5Type/tests/skel2.12 will need to find the Zope startup
+ # scripts (zopectl, runzope), which will likely be in this buildout
+ # bin directory.
+ zope_scripts = options.get('zope2-scripts',
+ options['bin-directory'])
+
+ init = init_template % dict(name=self.name,
+ zope_scripts=zope_scripts)
+
+ products = options.get('products', '')
+ test_products = options.get('test-products', products)
+ # Add Products to sys.path under the Products namespace
+ for product in products.splitlines():
+ if product:
+ init += add_product_path_template % dict(product_path=product)
+ # add test directories of selected products (defaulting to all
+ # products) to sys.path since that's where runUnitTest actually looks
+ # for them
+ for product in test_products.splitlines():
+ if product:
+ extra_paths.extend(
+ product_test_path for product_test_path in
+ glob.glob(os.path.join(product, '*', 'tests'))
+ )
+ #for product_test_path in glob.glob(
+ # os.path.join(product, '*', 'tests')):
+ # init += add_sys_path_template % dict(
+ # sys_path=product_test_path)
+
+ for bt5_path in options.get('bt5_path', '').splitlines():
+ bt5_path = bt5_path.strip()
+ if bt5_path:
+ init += add_bt5_path_template % dict(bt5_path=bt5_path)
+
+ # add parts/<instance>/tests to path because runUnitTest will
+ # guess it wrong
+ local_tests_path = os.path.join(self.instance_home, 'tests')
+ init += add_sys_path_template % dict(sys_path=local_tests_path)
+
+ # runUnitTest works in our parts directory, which will contain
+ # custom_zodb.py
+ if not os.path.exists(location):
+ os.mkdir(location)
+ init += set_env_and_chdir_template % dict(location=location)
+
+ # framework.py requires a Products directory, so create it here
+ # This is temporary, as we're getting rid of "framework.py"
+ products_dir = os.path.join(location, 'Products')
+ if not os.path.exists(products_dir):
+ os.mkdir(products_dir)
+
+ self.options['initialization'] = init
+ # reassign just to be on the safe side...
+ self.egg.extra_paths = extra_paths
+
+ # generate the script according to our configuration
+ self.egg.install()
+
+ return [location]
+
+ update = install
+
+init_template = '''
+import os
+from os.path import dirname, abspath
+
+# derive SOFTWARE_HOME from import location of Zope2
+try:
+ import Zope2
+except ImportError:
+ print >> sys.stderr, ("Zope2 could not be found. In the %(name)r part of the "
+ "buildout configuration, please specify either "
+ "software-home or zope2-location, or add Zope2 to the "
+ "list of eggs.")
+ raise
+else:
+ os.environ['SOFTWARE_HOME'] = abspath(dirname(dirname(Zope2.__file__)))
+
+# if under Zope 2.12, we need the location of the Zope2 startup scripts for the
+# substitutions in the skel2.12 directory
+ZOPE_SCRIPTS = %(zope_scripts)r
+if ZOPE_SCRIPTS is not None:
+ os.environ['ZOPE_SCRIPTS'] = ZOPE_SCRIPTS
+
+import Products
+
+# Testing needs to be imported, otherwise framework.py will guess it from
+# sys.path, which can be a zipped egg
+import Testing
+'''
+
+add_product_path_template = '''
+Products.__path__.append(%(product_path)r)'''
+
+add_sys_path_template = '''
+sys.path.append(%(sys_path)r)'''
+
+add_bt5_path_template = '''
+sys.argv.insert(1, %(bt5_path)r)
+sys.argv.insert(1, '--bt5_path')'''
+
+set_env_and_chdir_template = '''
+
+# execute framework.py, like in zope testcase
+os.environ['INSTANCE_HOME'] = %(location)r
+os.chdir(%(location)r)
+'''
+
Added: erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2install.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2install.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2install.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2install.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,85 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# Contains code from plone.recipe.zope2install
+#
+# 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, re, shutil, tempfile, urllib2, urlparse
+import setuptools.archive_util
+import plone.recipe.zope2install
+
+class Recipe(plone.recipe.zope2install.Recipe):
+
+ def __init__(self, buildout, name, options):
+ plone.recipe.zope2install.Recipe.__init__(self, buildout, name, options)
+ self.patch = os.path.join(self.buildout['buildout']['directory'],
+ options['patch'])
+
+ def install(self):
+ options = self.options
+ location = options['location']
+ download_dir = self.buildout['buildout']['download-cache']
+
+ if os.path.exists(location):
+ # if the zope installation exists and is shared, then we are done
+ # and don't return a path, so the shared installation doesn't get
+ # deleted on uninstall
+ if options.get('shared-zope') == 'true':
+ return []
+ else:
+ shutil.rmtree(location)
+
+ if self.svn:
+ assert os.system('svn co %s %s' % (options['svn'], location)
+ ) == 0
+ else:
+ if not os.path.isdir(download_dir):
+ os.mkdir(download_dir)
+
+ _, _, urlpath, _, _, _ = urlparse.urlparse(self.url)
+ tmp = tempfile.mkdtemp('buildout-'+self.name)
+ try:
+ fname = os.path.join(download_dir, urlpath.split('/')[-1])
+ # Have we already downloaded the file
+ if not os.path.exists(fname):
+ f = open(fname, 'wb')
+ try:
+ f.write(urllib2.urlopen(self.url).read())
+ except:
+ os.remove(fname)
+ raise
+ f.close()
+
+ setuptools.archive_util.unpack_archive(fname, tmp)
+ # The Zope tarballs have a Zope-<version> folder at the root
+ # level, so we need to move that one into the right place.
+ files = os.listdir(tmp)
+ shutil.move(os.path.join(tmp, files[0]), location)
+ finally:
+ shutil.rmtree(tmp)
+
+ os.chdir(location)
+
+ # erp5: apply a patch to zope before build
+ assert os.system('patch -p1 < %s' % self.patch) == 0
+
+ assert os.spawnl(
+ os.P_WAIT, options['executable'], options['executable'],
+ 'setup.py',
+ 'build_ext', '-i',
+ ) == 0
+
+ if self.url and options.get('shared-zope') == 'true':
+ # don't return path if the installation is shared
+ return []
+ return location
+
Added: erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2instance.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2instance.py?rev=30856&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2instance.py (added)
+++ erp5/trunk/utils/erp5.recipe/src/erp5/recipe/zope2instance.py [utf8] Wed Nov 25 15:35:51 2009
@@ -1,0 +1,30 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2009 Nexedi SARL 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 plone.recipe.zope2instance
+
+class Recipe(plone.recipe.zope2instance.Recipe):
+ def install(self):
+ # Override plone.recipe.zope2instance so as to create several
+ # directories used by ERP5.
+ ret = plone.recipe.zope2instance.Recipe.install(self)
+ options = self.options
+ location = options['location']
+
+ for directory in ('Constraint', 'Document', 'PropertySheet', 'tests'):
+ path = os.path.join(location, directory)
+ if not os.path.exists(path):
+ os.mkdir(path)
+
+ return ret
More information about the Erp5-report
mailing list