An algebraic approach to the Weyl groupoid