"""
Enable optimizations specific to the Python version, command line
and environment variables.

Only enable these optimizations if you don't control the exact Python version,
command line arguments and environment variables. Don't copy the resulting .pyc
files to another host because the environment may be different. For example,
-Qnew command line option of Python 2.7 changes the division operator.
"""

import sys

def setup_config(config):
    config.enable('platform')
    config.enable('pythonbin')

    # On Python 2, the optimizer enables optimization on a/b operator
    # when this feature is used, because the behaviour depends on the
    # -Q command line option

    config.add_constant('__debug__', __debug__)
    for attr in dir(sys.flags):
        if attr.startswith(("_", "n_")):
            continue
        if attr in ("count", "index"):
            continue
        value = getattr(sys.flags, attr)
        config.add_constant('sys.flags.%s' % attr, value)

    config.add_constant('sys.dont_write_bytecode', sys.dont_write_bytecode)

