def evaluate_condition(cond, variables=None):
    """
    Evaluates a condition inserted in a :epkg:`yml` file.

    @param      cond        (str) condition
    @param      variables   (dict|None) dictionary
    @return                 boolean

    Example of a condition::

        [ ${PYTHON} == "C:\\Python370_x64" ]
    """
    if variables is not None:
        for k, v in variables.items():
            rep = "${%s}" % k
            vv = '"%s"' % v
            cond = cond.replace(rep, vv)
            cond = cond.replace(rep.upper(), vv)
    cond = cond.strip()
    if cond.startswith("[") and cond.endswith("]"):
        e = eval(cond)
        return all(e)
    try:
        return eval(cond)
    except SyntaxError as e:
        raise SyntaxError(
            "Unable to interpret '{0}'\nvariables: {1}".format(cond, variables)) from e