python: Factor out lib_cellar

Closes #26705.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>