def ensure_has_source_dir(self, parent_dir):<EOL>
if self.source_dir is None:<EOL><INDENT>self.source_dir = self.build_location(parent_dir)<EOL><DEDENT>return self.source_dir<EOL>
Ensure that a source_dir is set.

        This will create a temporary build dir if the name of the requirement
        isn't known yet.

        :param parent_dir: The ideal pip parent_dir for the source_dir.
            Generally src_dir for editables and build_dir for sdists.
        :return: self.source_dir