Move checkout to CFFI and add a target directory option

Having it at the python level should also make it easer to extend with more options in the future as needed.