@contextmanager<EOL>def make_zip(directory, extension="<STR_LIT>"):
tmpdir = None<EOL>try:<EOL><INDENT>tmpdir = tempfile.mkdtemp()<EOL>path_prefix = os.path.join(tmpdir, "<STR_LIT:code>")<EOL>zipfile_current_path = shutil.make_archive(path_prefix, '<STR_LIT>', directory)<EOL>expected_path = path_prefix + "<STR_LIT:.>" + extension<EOL>os.rename(zipfile_current_path, expected_path)<EOL>yield expected_path<EOL><DEDENT>finally:<EOL><INDENT>if tmpdir:<EOL><INDENT>shutil.rmtree(tmpdir)<EOL><DEDENT><DEDENT>
Zip up the contents of the directory and return path to the zipfile. This method can be used inside a ``with``
statement so it will cleanup the zipfile after the context exists.

:param string directory: Path to the directory to zip up
:param string extension: Extension for the file
:return string: Path to the zip file