Refactor setup.py reuse some of the code