fix build_dir copying

Found that with the changes made over the past couple of days, using this feature with Sage was still broken. This resolves all edge cases Sage exposed.