Move sys imports to functions to support conda-build