[Checkins] SVN: zc.buildout/trunk/zc.recipe.egg_/ support dicts passed as options to zc.recipe.egg, with a test.
Gary Poster
gary.poster at canonical.com
Mon Aug 23 14:41:38 EDT 2010
Log message for revision 115894:
support dicts passed as options to zc.recipe.egg, with a test.
Changed:
U zc.buildout/trunk/zc.recipe.egg_/CHANGES.txt
U zc.buildout/trunk/zc.recipe.egg_/setup.py
U zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/api.txt
U zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/egg.py
U zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py
-=-
Modified: zc.buildout/trunk/zc.recipe.egg_/CHANGES.txt
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/CHANGES.txt 2010-08-23 16:58:08 UTC (rev 115893)
+++ zc.buildout/trunk/zc.recipe.egg_/CHANGES.txt 2010-08-23 18:41:38 UTC (rev 115894)
@@ -1,10 +1,11 @@
Change History
**************
-1.3.1 (unreleased)
+1.3.1 (2010-08-23)
==================
-(no changes so far)
+- Support recipes that are using zc.recipe.egg by passing in a dict, rather
+ than a zc.buildout.buildout.Options object as was expected/tested.
1.3.0 (2010-08-23)
==================
Modified: zc.buildout/trunk/zc.recipe.egg_/setup.py
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/setup.py 2010-08-23 16:58:08 UTC (rev 115893)
+++ zc.buildout/trunk/zc.recipe.egg_/setup.py 2010-08-23 18:41:38 UTC (rev 115894)
@@ -14,7 +14,7 @@
"""Setup for zc.recipe.egg package
"""
-version = '1.3.1dev'
+version = '1.3.1'
import os
from setuptools import setup, find_packages
Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/api.txt
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/api.txt 2010-08-23 16:58:08 UTC (rev 115893)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/api.txt 2010-08-23 18:41:38 UTC (rev 115894)
@@ -122,7 +122,6 @@
If we use the extra-paths option:
-
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
@@ -151,4 +150,3 @@
other 1.0
demoneeded 1.2c1
extra paths: ['/foo/bar', '/spam/eggs']
-
Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/egg.py
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/egg.py 2010-08-23 16:58:08 UTC (rev 115893)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/egg.py 2010-08-23 18:41:38 UTC (rev 115894)
@@ -16,7 +16,8 @@
$Id$
"""
-import logging, os, re, zipfile
+import UserDict, logging, os, re, zipfile
+import zc.buildout
import zc.buildout.easy_install
@@ -27,6 +28,11 @@
def __init__(self, buildout, name, options):
self.buildout = buildout
self.name = self.default_eggs = name
+ if getattr(options, 'query_bool', None) is None:
+ # Someone is not passing us a zc.buildout.buildout.Options
+ # object. Maybe we should have a deprecation warning.
+ # Whatever.
+ options = _BackwardsSupportOption(options)
self.options = options
b_options = buildout['buildout']
links = options.get('find-links', b_options['find-links'])
@@ -190,3 +196,32 @@
)
Egg = Scripts
+
+
+class _BackwardsSupportOption(UserDict.UserDict):
+
+ def query_bool(self, name, default=None):
+ """Given a name, return a boolean value for that name.
+
+ ``default``, if given, should be 'true', 'false', or None.
+ """
+ if default is not None:
+ value = self.setdefault(name, default)
+ else:
+ value = self.get(name)
+ if value is None:
+ return value
+ return _convert_bool(name, value)
+
+ def get_bool(self, name):
+ """Given a name, return a boolean value for that name.
+ """
+ return _convert_bool(name, self[name])
+
+
+def _convert_bool(name, value):
+ if value not in ('true', 'false'):
+ raise zc.buildout.UserError(
+ 'Invalid value for %s option: %s' % (name, value))
+ else:
+ return value == 'true'
Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py 2010-08-23 16:58:08 UTC (rev 115893)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py 2010-08-23 18:41:38 UTC (rev 115894)
@@ -29,6 +29,40 @@
return d
return dirname(os.path.dirname(d), level-1)
+def testUsingDictAsOptions():
+ """
+Some recipes using zc.recipe.egg have been passing dictionaries rather than
+zc.buildout.buildout.Options objects. That's unexpected, but to save
+complaints, we'll support it.
+
+Note that this test intends to show that a dictionary can be used as an
+options object. It also uses a dictionary for the buildout object, which is
+not intended.
+
+ >>> import zc.buildout.buildout
+ >>> import zc.recipe.egg
+ >>> faux_egg_options = {
+ ... 'find-links': 'example.com',
+ ... 'bin-directory': '/somewhere/over/rainbow'}
+ >>> faux_buildout_options = zc.buildout.buildout._unannotate_section(
+ ... zc.buildout.buildout._buildout_default_options.copy())
+ >>> faux_buildout = {
+ ... 'faux': faux_egg_options, 'buildout': faux_buildout_options}
+ >>> scripts = zc.recipe.egg.Scripts(
+ ... faux_buildout, 'faux', faux_egg_options)
+ >>> scripts.links
+ ['example.com']
+ >>> import zc.buildout.easy_install
+ >>> old_install = zc.buildout.easy_install.install
+ >>> old_scripts = zc.buildout.easy_install.scripts
+ >>> def whatever(*args, **kwargs): pass
+ >>> zc.buildout.easy_install.install = whatever
+ >>> zc.buildout.easy_install.scripts = whatever
+ >>> scripts.install() # This used to fail!
+ >>> zc.buildout.easy_install.install = old_install
+ >>> zc.buildout.easy_install.scripts = old_scripts
+"""
+
def setUp(test):
zc.buildout.tests.easy_install_SetUp(test)
zc.buildout.testing.install_develop('zc.recipe.egg', test)
@@ -96,7 +130,9 @@
(re.compile('extdemo[.]pyd'), 'extdemo.so')
]),
),
-
+ doctest.DocTestSuite(
+ setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
+ ),
))
if sys.version_info[:2] != (2, 4):
More information about the checkins
mailing list