Commit 56a63e64 authored by Rafael Monnerat's avatar Rafael Monnerat

Implement compatibility with buildout2

  And it is also backward compatible with buildout<2 and with current tests
parent c4f9a9e1
...@@ -13,7 +13,15 @@ import subprocess ...@@ -13,7 +13,15 @@ import subprocess
import sys import sys
import zc.buildout import zc.buildout
from zc.buildout.download import Download from zc.buildout.download import Download
try:
# import from zc.buildout>2
from zc.buildout.buildout import bool_option
except:
def bool_option(options, name, defaults=None):
if getattr(options, "query_bool", None) is None:
from zc.buildout.buildout import Options
options = Options({}, "options", options)
return options.query_bool(name, defaults)
class Recipe(object): class Recipe(object):
"""zc.buildout recipe for compiling and installing software""" """zc.buildout recipe for compiling and installing software"""
...@@ -51,8 +59,8 @@ class Recipe(object): ...@@ -51,8 +59,8 @@ class Recipe(object):
options['url'] = options.get('url', '').strip() options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip() options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '') options['promises'] = options.get('promises', '')
default_strip = buildout['buildout'].query_bool('strip', 'true') default_strip = bool_option(buildout['buildout'], 'strip', 'true')
options['strip'] = options.query_bool('strip', default_strip and 'true' or 'false') options['strip'] = bool_option(options, 'strip', default_strip and 'true' or 'false')
# Check dependencies, all the dependent parts will be installed first. It # Check dependencies, all the dependent parts will be installed first. It
# seems once part is referenced, for example, self.buildout[part], it will # seems once part is referenced, for example, self.buildout[part], it will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment