There is paper at David Eberly site "Fitting 3D Data with a Cylinder" that describes math basics and shows pseudocode.
You can also refer to C++ code in Geometric Tools Engine at the same site. I think that some auxiliary math functions like matrix inverse etc could be implemented in NymPy.