Managed to get it working by creating a zip file using ZipFile and adding the stuff I wanted in order, and with the directories I ran a for loop over the directory to add all the files inside of it onto new directories I created inside the zip file.
Example code here:
os.chdir("foo\bar")
with ZipFile("foobar.zip", "w", ZIP_STORED) as foo:
foo.write("mimetype")
foo.close()
with ZipFile("foobar.zip", "a", ZIP_STORED) as foo:
for file in os.listdir("directory1"):
fullPath = os.path.join("directory1", file)
foo.write(fullPath)
os.replace("foobar.zip", "foo/bar/foobar.epub")