build_python_modules: Many robustness fixes