def align(items, attr, strength='weak'):
    """
    Helper function to generate alignment constraints

    Parameters
    ----------
    items: a list of rects to align.
    attr: which attribute to align.

    Returns
    -------
    cons: list of constraints describing the alignment
    """
    cons = []
    for i in items[1:]:
        cons.append((getattr(items[0], attr) == getattr(i, attr)) | strength)
    return cons