diff --git a/setup.py b/setup.py index 3412dab..25ab94d 100755 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ from setupbase import ( check_for_dependencies, record_commit_info, ) -from setupext.setupext import check_for_readline +from setupext import setupext isfile = os.path.isfile pjoin = os.path.join @@ -220,9 +220,10 @@ if 'setuptools' in sys.modules: test='nose>=0.10.1', ) requires = setup_args.setdefault('install_requires', []) - if not check_for_readline(): + setupext.display_status = False + if not setupext.check_for_readline(): if sys.platform == 'darwin': - requires.append('readline') + requires.append('readline') elif sys.platform.startswith('win'): requires.append('pyreadline') else: diff --git a/setupext/setupext.py b/setupext/setupext.py index 4d48ef8..ed8ae34 100644 --- a/setupext/setupext.py +++ b/setupext/setupext.py @@ -18,29 +18,35 @@ from textwrap import fill display_status=True -if display_status: - def print_line(char='='): - print char * 76 - - def print_status(package, status): - initial_indent = "%22s: " % package - indent = ' ' * 24 - print fill(str(status), width=76, - initial_indent=initial_indent, - subsequent_indent=indent) - - def print_message(message): - indent = ' ' * 24 + "* " - print fill(str(message), width=76, - initial_indent=indent, - subsequent_indent=indent) - - def print_raw(section): - print section -else: - def print_line(*args, **kwargs): - pass - print_status = print_message = print_raw = print_line +def check_display(f): + """decorator to allow display methods to be muted by mod.display_status""" + def maybe_display(*args, **kwargs): + if display_status: + return f(*args, **kwargs) + return maybe_display + +@check_display +def print_line(char='='): + print char * 76 + +@check_display +def print_status(package, status): + initial_indent = "%22s: " % package + indent = ' ' * 24 + print fill(str(status), width=76, + initial_indent=initial_indent, + subsequent_indent=indent) + +@check_display +def print_message(message): + indent = ' ' * 24 + "* " + print fill(str(message), width=76, + initial_indent=indent, + subsequent_indent=indent) + +@check_display +def print_raw(section): + print section #------------------------------------------------------------------------------- # Tests for specific packages