refine pybuild logic